box-node-sdk 3.8.0 → 3.8.2

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 (449) hide show
  1. package/README.md +89 -69
  2. package/config/package.schema.json +42 -42
  3. package/lib/api-request-manager.d.ts +0 -2
  4. package/lib/api-request-manager.js.map +1 -1
  5. package/lib/api-request.d.ts +0 -3
  6. package/lib/api-request.js.map +1 -1
  7. package/lib/box-client.d.ts +7 -7
  8. package/lib/box-client.js +6 -3
  9. package/lib/box-client.js.map +1 -1
  10. package/lib/box-node-sdk.d.ts +1 -3
  11. package/lib/box-node-sdk.js +26 -10
  12. package/lib/box-node-sdk.js.map +1 -1
  13. package/lib/chunked-uploader.d.ts +0 -5
  14. package/lib/chunked-uploader.js.map +1 -1
  15. package/lib/enterprise-event-stream.d.ts +0 -1
  16. package/lib/enterprise-event-stream.js +3 -3
  17. package/lib/enterprise-event-stream.js.map +1 -1
  18. package/lib/event-stream.d.ts +0 -2
  19. package/lib/event-stream.js.map +1 -1
  20. package/lib/managers/ai.generated.js.map +1 -1
  21. package/lib/managers/collaboration-allowlist.js.map +1 -1
  22. package/lib/managers/collaborations.d.ts +3 -3
  23. package/lib/managers/collaborations.js +23 -23
  24. package/lib/managers/collaborations.js.map +1 -1
  25. package/lib/managers/collections.js.map +1 -1
  26. package/lib/managers/comments.js.map +1 -1
  27. package/lib/managers/device-pins.js.map +1 -1
  28. package/lib/managers/enterprise.js.map +1 -1
  29. package/lib/managers/events.d.ts +0 -1
  30. package/lib/managers/events.js +3 -1
  31. package/lib/managers/events.js.map +1 -1
  32. package/lib/managers/file-requests-manager.d.ts +2 -2
  33. package/lib/managers/file-requests-manager.js +1 -1
  34. package/lib/managers/file-requests-manager.js.map +1 -1
  35. package/lib/managers/files.d.ts +1 -4
  36. package/lib/managers/files.js +6 -2
  37. package/lib/managers/files.js.map +1 -1
  38. package/lib/managers/folders.d.ts +1 -1
  39. package/lib/managers/folders.js +3 -1
  40. package/lib/managers/folders.js.map +1 -1
  41. package/lib/managers/groups.js +2 -2
  42. package/lib/managers/groups.js.map +1 -1
  43. package/lib/managers/integration-mappings.js.map +1 -1
  44. package/lib/managers/legal-hold-policies.js.map +1 -1
  45. package/lib/managers/metadata.js.map +1 -1
  46. package/lib/managers/recent-items.js.map +1 -1
  47. package/lib/managers/retention-policies.d.ts +1 -1
  48. package/lib/managers/retention-policies.js.map +1 -1
  49. package/lib/managers/search.d.ts +1 -1
  50. package/lib/managers/search.js.map +1 -1
  51. package/lib/managers/shared-items.js.map +1 -1
  52. package/lib/managers/shield-information-barrier-reports.generated.js.map +1 -1
  53. package/lib/managers/shield-information-barrier-segment-members.generated.js.map +1 -1
  54. package/lib/managers/shield-information-barrier-segment-restrictions.generated.js.map +1 -1
  55. package/lib/managers/shield-information-barrier-segments.generated.js.map +1 -1
  56. package/lib/managers/shield-information-barriers.generated.js.map +1 -1
  57. package/lib/managers/sign-requests.generated.js.map +1 -1
  58. package/lib/managers/sign-templates.generated.js.map +1 -1
  59. package/lib/managers/storage-policies.js.map +1 -1
  60. package/lib/managers/tasks.js.map +1 -1
  61. package/lib/managers/terms-of-service.js.map +1 -1
  62. package/lib/managers/trash.js.map +1 -1
  63. package/lib/managers/users.d.ts +0 -3
  64. package/lib/managers/users.js +1 -1
  65. package/lib/managers/users.js.map +1 -1
  66. package/lib/managers/web-links.js +3 -1
  67. package/lib/managers/web-links.js.map +1 -1
  68. package/lib/managers/webhooks.d.ts +11 -11
  69. package/lib/managers/webhooks.js +24 -14
  70. package/lib/managers/webhooks.js.map +1 -1
  71. package/lib/schemas/collaboration-update.d.ts +1 -1
  72. package/lib/schemas/collaboration.d.ts +3 -3
  73. package/lib/schemas/collaborations.d.ts +1 -1
  74. package/lib/schemas/file-request.d.ts +2 -2
  75. package/lib/sessions/app-auth-session.js.map +1 -1
  76. package/lib/sessions/basic-session.d.ts +0 -1
  77. package/lib/sessions/basic-session.js.map +1 -1
  78. package/lib/sessions/ccg-session.js.map +1 -1
  79. package/lib/sessions/persistent-session.js.map +1 -1
  80. package/lib/token-manager.js +4 -2
  81. package/lib/token-manager.js.map +1 -1
  82. package/lib/util/config.d.ts +0 -2
  83. package/lib/util/config.js +18 -8
  84. package/lib/util/config.js.map +1 -1
  85. package/lib/util/errors.js +17 -7
  86. package/lib/util/errors.js.map +1 -1
  87. package/lib/util/exponential-backoff.js.map +1 -1
  88. package/lib/util/paging-iterator.js +17 -7
  89. package/lib/util/paging-iterator.js.map +1 -1
  90. package/lib/util/serializable.js.map +1 -1
  91. package/lib/util/url-path.js.map +1 -1
  92. package/lib-esm/api-request-manager.d.ts +36 -0
  93. package/lib-esm/api-request-manager.js +78 -0
  94. package/lib-esm/api-request-manager.js.map +1 -0
  95. package/lib-esm/api-request.d.ts +135 -0
  96. package/lib-esm/api-request.js +282 -0
  97. package/lib-esm/api-request.js.map +1 -0
  98. package/lib-esm/box-client.d.ts +274 -0
  99. package/lib-esm/box-client.js +594 -0
  100. package/lib-esm/box-client.js.map +1 -0
  101. package/lib-esm/box-node-sdk.d.ts +227 -0
  102. package/lib-esm/box-node-sdk.js +373 -0
  103. package/lib-esm/box-node-sdk.js.map +1 -0
  104. package/lib-esm/chunked-uploader.d.ts +128 -0
  105. package/lib-esm/chunked-uploader.js +276 -0
  106. package/lib-esm/chunked-uploader.js.map +1 -0
  107. package/lib-esm/enterprise-event-stream.d.ts +82 -0
  108. package/lib-esm/enterprise-event-stream.js +205 -0
  109. package/lib-esm/enterprise-event-stream.js.map +1 -0
  110. package/lib-esm/event-stream.d.ts +91 -0
  111. package/lib-esm/event-stream.js +277 -0
  112. package/lib-esm/event-stream.js.map +1 -0
  113. package/lib-esm/managers/ai.generated.d.ts +58 -0
  114. package/lib-esm/managers/ai.generated.js +66 -0
  115. package/lib-esm/managers/ai.generated.js.map +1 -0
  116. package/lib-esm/managers/collaboration-allowlist.d.ts +133 -0
  117. package/lib-esm/managers/collaboration-allowlist.js +194 -0
  118. package/lib-esm/managers/collaboration-allowlist.js.map +1 -0
  119. package/lib-esm/managers/collaborations.d.ts +173 -0
  120. package/lib-esm/managers/collaborations.js +252 -0
  121. package/lib-esm/managers/collaborations.js.map +1 -0
  122. package/lib-esm/managers/collections.d.ts +42 -0
  123. package/lib-esm/managers/collections.js +62 -0
  124. package/lib-esm/managers/collections.js.map +1 -0
  125. package/lib-esm/managers/comments.d.ts +103 -0
  126. package/lib-esm/managers/comments.js +175 -0
  127. package/lib-esm/managers/comments.js.map +1 -0
  128. package/lib-esm/managers/device-pins.d.ts +52 -0
  129. package/lib-esm/managers/device-pins.js +91 -0
  130. package/lib-esm/managers/device-pins.js.map +1 -0
  131. package/lib-esm/managers/enterprise.d.ts +164 -0
  132. package/lib-esm/managers/enterprise.js +193 -0
  133. package/lib-esm/managers/enterprise.js.map +1 -0
  134. package/lib-esm/managers/events.d.ts +222 -0
  135. package/lib-esm/managers/events.js +295 -0
  136. package/lib-esm/managers/events.js.map +1 -0
  137. package/lib-esm/managers/file-requests-manager.d.ts +56 -0
  138. package/lib-esm/managers/file-requests-manager.js +81 -0
  139. package/lib-esm/managers/file-requests-manager.js.map +1 -0
  140. package/lib-esm/managers/files.d.ts +817 -0
  141. package/lib-esm/managers/files.js +1408 -0
  142. package/lib-esm/managers/files.js.map +1 -0
  143. package/lib-esm/managers/folders.d.ts +396 -0
  144. package/lib-esm/managers/folders.js +570 -0
  145. package/lib-esm/managers/folders.js.map +1 -0
  146. package/lib-esm/managers/groups.d.ts +213 -0
  147. package/lib-esm/managers/groups.js +289 -0
  148. package/lib-esm/managers/groups.js.map +1 -0
  149. package/lib-esm/managers/integration-mappings.d.ts +116 -0
  150. package/lib-esm/managers/integration-mappings.js +101 -0
  151. package/lib-esm/managers/integration-mappings.js.map +1 -0
  152. package/lib-esm/managers/legal-hold-policies.d.ts +190 -0
  153. package/lib-esm/managers/legal-hold-policies.js +254 -0
  154. package/lib-esm/managers/legal-hold-policies.js.map +1 -0
  155. package/lib-esm/managers/metadata.d.ts +232 -0
  156. package/lib-esm/managers/metadata.js +288 -0
  157. package/lib-esm/managers/metadata.js.map +1 -0
  158. package/lib-esm/managers/recent-items.d.ts +38 -0
  159. package/lib-esm/managers/recent-items.js +49 -0
  160. package/lib-esm/managers/recent-items.js.map +1 -0
  161. package/lib-esm/managers/retention-policies.d.ts +308 -0
  162. package/lib-esm/managers/retention-policies.js +374 -0
  163. package/lib-esm/managers/retention-policies.js.map +1 -0
  164. package/lib-esm/managers/search.d.ts +82 -0
  165. package/lib-esm/managers/search.js +90 -0
  166. package/lib-esm/managers/search.js.map +1 -0
  167. package/lib-esm/managers/shared-items.d.ts +33 -0
  168. package/lib-esm/managers/shared-items.js +74 -0
  169. package/lib-esm/managers/shared-items.js.map +1 -0
  170. package/lib-esm/managers/shield-information-barrier-reports.generated.d.ts +65 -0
  171. package/lib-esm/managers/shield-information-barrier-reports.generated.js +65 -0
  172. package/lib-esm/managers/shield-information-barrier-reports.generated.js.map +1 -0
  173. package/lib-esm/managers/shield-information-barrier-segment-members.generated.d.ts +83 -0
  174. package/lib-esm/managers/shield-information-barrier-segment-members.generated.js +83 -0
  175. package/lib-esm/managers/shield-information-barrier-segment-members.generated.js.map +1 -0
  176. package/lib-esm/managers/shield-information-barrier-segment-restrictions.generated.d.ts +84 -0
  177. package/lib-esm/managers/shield-information-barrier-segment-restrictions.generated.js +84 -0
  178. package/lib-esm/managers/shield-information-barrier-segment-restrictions.generated.js.map +1 -0
  179. package/lib-esm/managers/shield-information-barrier-segments.generated.d.ts +98 -0
  180. package/lib-esm/managers/shield-information-barrier-segments.generated.js +99 -0
  181. package/lib-esm/managers/shield-information-barrier-segments.generated.js.map +1 -0
  182. package/lib-esm/managers/shield-information-barriers.generated.d.ts +79 -0
  183. package/lib-esm/managers/shield-information-barriers.generated.js +83 -0
  184. package/lib-esm/managers/shield-information-barriers.generated.js.map +1 -0
  185. package/lib-esm/managers/sign-requests.generated.d.ts +93 -0
  186. package/lib-esm/managers/sign-requests.generated.js +97 -0
  187. package/lib-esm/managers/sign-requests.generated.js.map +1 -0
  188. package/lib-esm/managers/sign-templates.generated.d.ts +51 -0
  189. package/lib-esm/managers/sign-templates.generated.js +49 -0
  190. package/lib-esm/managers/sign-templates.generated.js.map +1 -0
  191. package/lib-esm/managers/storage-policies.d.ts +86 -0
  192. package/lib-esm/managers/storage-policies.js +174 -0
  193. package/lib-esm/managers/storage-policies.js.map +1 -0
  194. package/lib-esm/managers/tasks.d.ts +161 -0
  195. package/lib-esm/managers/tasks.js +243 -0
  196. package/lib-esm/managers/tasks.js.map +1 -0
  197. package/lib-esm/managers/terms-of-service.d.ts +161 -0
  198. package/lib-esm/managers/terms-of-service.js +283 -0
  199. package/lib-esm/managers/terms-of-service.js.map +1 -0
  200. package/lib-esm/managers/trash.d.ts +30 -0
  201. package/lib-esm/managers/trash.js +47 -0
  202. package/lib-esm/managers/trash.js.map +1 -0
  203. package/lib-esm/managers/users.d.ts +171 -0
  204. package/lib-esm/managers/users.js +230 -0
  205. package/lib-esm/managers/users.js.map +1 -0
  206. package/lib-esm/managers/web-links.d.ts +127 -0
  207. package/lib-esm/managers/web-links.js +200 -0
  208. package/lib-esm/managers/web-links.js.map +1 -0
  209. package/lib-esm/managers/webhooks.d.ts +169 -0
  210. package/lib-esm/managers/webhooks.js +398 -0
  211. package/lib-esm/managers/webhooks.js.map +1 -0
  212. package/lib-esm/schemas/ai-agent-ask.generated.d.ts +17 -0
  213. package/lib-esm/schemas/ai-agent-ask.generated.js +3 -0
  214. package/lib-esm/schemas/ai-agent-ask.generated.js.map +1 -0
  215. package/lib-esm/schemas/ai-agent-basic-gen-tool.generated.d.ts +14 -0
  216. package/lib-esm/schemas/ai-agent-basic-gen-tool.generated.js +3 -0
  217. package/lib-esm/schemas/ai-agent-basic-gen-tool.generated.js.map +1 -0
  218. package/lib-esm/schemas/ai-agent-basic-text-tool-ask.generated.d.ts +34 -0
  219. package/lib-esm/schemas/ai-agent-basic-text-tool-ask.generated.js +3 -0
  220. package/lib-esm/schemas/ai-agent-basic-text-tool-ask.generated.js.map +1 -0
  221. package/lib-esm/schemas/ai-agent-basic-text-tool-text-gen.generated.d.ts +36 -0
  222. package/lib-esm/schemas/ai-agent-basic-text-tool-text-gen.generated.js +3 -0
  223. package/lib-esm/schemas/ai-agent-basic-text-tool-text-gen.generated.js.map +1 -0
  224. package/lib-esm/schemas/ai-agent-long-text-tool.generated.d.ts +9 -0
  225. package/lib-esm/schemas/ai-agent-long-text-tool.generated.js +3 -0
  226. package/lib-esm/schemas/ai-agent-long-text-tool.generated.js.map +1 -0
  227. package/lib-esm/schemas/ai-agent-text-gen.generated.d.ts +14 -0
  228. package/lib-esm/schemas/ai-agent-text-gen.generated.js +3 -0
  229. package/lib-esm/schemas/ai-agent-text-gen.generated.js.map +1 -0
  230. package/lib-esm/schemas/ai-ask.generated.d.ts +40 -0
  231. package/lib-esm/schemas/ai-ask.generated.js +3 -0
  232. package/lib-esm/schemas/ai-ask.generated.js.map +1 -0
  233. package/lib-esm/schemas/ai-citation.generated.d.ts +27 -0
  234. package/lib-esm/schemas/ai-citation.generated.js +3 -0
  235. package/lib-esm/schemas/ai-citation.generated.js.map +1 -0
  236. package/lib-esm/schemas/ai-dialogue-history.generated.d.ts +22 -0
  237. package/lib-esm/schemas/ai-dialogue-history.generated.js +3 -0
  238. package/lib-esm/schemas/ai-dialogue-history.generated.js.map +1 -0
  239. package/lib-esm/schemas/ai-llm-endpoint-params-google.generated.d.ts +31 -0
  240. package/lib-esm/schemas/ai-llm-endpoint-params-google.generated.js +3 -0
  241. package/lib-esm/schemas/ai-llm-endpoint-params-google.generated.js.map +1 -0
  242. package/lib-esm/schemas/ai-llm-endpoint-params-open-ai.generated.d.ts +43 -0
  243. package/lib-esm/schemas/ai-llm-endpoint-params-open-ai.generated.js +3 -0
  244. package/lib-esm/schemas/ai-llm-endpoint-params-open-ai.generated.js.map +1 -0
  245. package/lib-esm/schemas/ai-response-full.generated.d.ts +12 -0
  246. package/lib-esm/schemas/ai-response-full.generated.js +3 -0
  247. package/lib-esm/schemas/ai-response-full.generated.js.map +1 -0
  248. package/lib-esm/schemas/ai-response.generated.d.ts +22 -0
  249. package/lib-esm/schemas/ai-response.generated.js +3 -0
  250. package/lib-esm/schemas/ai-response.generated.js.map +1 -0
  251. package/lib-esm/schemas/ai-text-gen.generated.d.ts +30 -0
  252. package/lib-esm/schemas/ai-text-gen.generated.js +3 -0
  253. package/lib-esm/schemas/ai-text-gen.generated.js.map +1 -0
  254. package/lib-esm/schemas/collaboration-create.d.ts +5 -0
  255. package/lib-esm/schemas/collaboration-create.js +3 -0
  256. package/lib-esm/schemas/collaboration-create.js.map +1 -0
  257. package/lib-esm/schemas/collaboration-update.d.ts +7 -0
  258. package/lib-esm/schemas/collaboration-update.js +3 -0
  259. package/lib-esm/schemas/collaboration-update.js.map +1 -0
  260. package/lib-esm/schemas/collaboration.d.ts +108 -0
  261. package/lib-esm/schemas/collaboration.js +3 -0
  262. package/lib-esm/schemas/collaboration.js.map +1 -0
  263. package/lib-esm/schemas/collaborations.d.ts +13 -0
  264. package/lib-esm/schemas/collaborations.js +3 -0
  265. package/lib-esm/schemas/collaborations.js.map +1 -0
  266. package/lib-esm/schemas/enterprise-base.generated.d.ts +18 -0
  267. package/lib-esm/schemas/enterprise-base.generated.js +3 -0
  268. package/lib-esm/schemas/enterprise-base.generated.js.map +1 -0
  269. package/lib-esm/schemas/file-base.generated.d.ts +32 -0
  270. package/lib-esm/schemas/file-base.generated.js +3 -0
  271. package/lib-esm/schemas/file-base.generated.js.map +1 -0
  272. package/lib-esm/schemas/file-mini.generated.d.ts +41 -0
  273. package/lib-esm/schemas/file-mini.generated.js +3 -0
  274. package/lib-esm/schemas/file-mini.generated.js.map +1 -0
  275. package/lib-esm/schemas/file-request.d.ts +41 -0
  276. package/lib-esm/schemas/file-request.js +3 -0
  277. package/lib-esm/schemas/file-request.js.map +1 -0
  278. package/lib-esm/schemas/file-version-base.generated.d.ts +19 -0
  279. package/lib-esm/schemas/file-version-base.generated.js +3 -0
  280. package/lib-esm/schemas/file-version-base.generated.js.map +1 -0
  281. package/lib-esm/schemas/file-version-mini.generated.d.ts +14 -0
  282. package/lib-esm/schemas/file-version-mini.generated.js +3 -0
  283. package/lib-esm/schemas/file-version-mini.generated.js.map +1 -0
  284. package/lib-esm/schemas/folder-base.generated.d.ts +32 -0
  285. package/lib-esm/schemas/folder-base.generated.js +3 -0
  286. package/lib-esm/schemas/folder-base.generated.js.map +1 -0
  287. package/lib-esm/schemas/folder-mini.generated.d.ts +31 -0
  288. package/lib-esm/schemas/folder-mini.generated.js +3 -0
  289. package/lib-esm/schemas/folder-mini.generated.js.map +1 -0
  290. package/lib-esm/schemas/index.d.ts +15 -0
  291. package/lib-esm/schemas/index.generated.d.ts +52 -0
  292. package/lib-esm/schemas/index.generated.js +69 -0
  293. package/lib-esm/schemas/index.generated.js.map +1 -0
  294. package/lib-esm/schemas/index.js +32 -0
  295. package/lib-esm/schemas/index.js.map +1 -0
  296. package/lib-esm/schemas/integration-mapping-base.d.ts +23 -0
  297. package/lib-esm/schemas/integration-mapping-base.js +3 -0
  298. package/lib-esm/schemas/integration-mapping-base.js.map +1 -0
  299. package/lib-esm/schemas/integration-mapping-box-item-slack.d.ts +17 -0
  300. package/lib-esm/schemas/integration-mapping-box-item-slack.js +3 -0
  301. package/lib-esm/schemas/integration-mapping-box-item-slack.js.map +1 -0
  302. package/lib-esm/schemas/integration-mapping-partner-item-slack.d.ts +27 -0
  303. package/lib-esm/schemas/integration-mapping-partner-item-slack.js +3 -0
  304. package/lib-esm/schemas/integration-mapping-partner-item-slack.js.map +1 -0
  305. package/lib-esm/schemas/integration-mapping-slack-create-request.d.ts +12 -0
  306. package/lib-esm/schemas/integration-mapping-slack-create-request.js +3 -0
  307. package/lib-esm/schemas/integration-mapping-slack-create-request.js.map +1 -0
  308. package/lib-esm/schemas/integration-mapping-slack-options.d.ts +16 -0
  309. package/lib-esm/schemas/integration-mapping-slack-options.js +3 -0
  310. package/lib-esm/schemas/integration-mapping-slack-options.js.map +1 -0
  311. package/lib-esm/schemas/integration-mapping.d.ts +55 -0
  312. package/lib-esm/schemas/integration-mapping.js +3 -0
  313. package/lib-esm/schemas/integration-mapping.js.map +1 -0
  314. package/lib-esm/schemas/integration-mappings.d.ts +27 -0
  315. package/lib-esm/schemas/integration-mappings.js +3 -0
  316. package/lib-esm/schemas/integration-mappings.js.map +1 -0
  317. package/lib-esm/schemas/shield-information-barrier-base.generated.d.ts +18 -0
  318. package/lib-esm/schemas/shield-information-barrier-base.generated.js +3 -0
  319. package/lib-esm/schemas/shield-information-barrier-base.generated.js.map +1 -0
  320. package/lib-esm/schemas/shield-information-barrier-reference.generated.d.ts +9 -0
  321. package/lib-esm/schemas/shield-information-barrier-reference.generated.js +3 -0
  322. package/lib-esm/schemas/shield-information-barrier-reference.generated.js.map +1 -0
  323. package/lib-esm/schemas/shield-information-barrier-report-base.generated.d.ts +18 -0
  324. package/lib-esm/schemas/shield-information-barrier-report-base.generated.js +3 -0
  325. package/lib-esm/schemas/shield-information-barrier-report-base.generated.js.map +1 -0
  326. package/lib-esm/schemas/shield-information-barrier-report-details.generated.d.ts +9 -0
  327. package/lib-esm/schemas/shield-information-barrier-report-details.generated.js +3 -0
  328. package/lib-esm/schemas/shield-information-barrier-report-details.generated.js.map +1 -0
  329. package/lib-esm/schemas/shield-information-barrier-report.generated.d.ts +32 -0
  330. package/lib-esm/schemas/shield-information-barrier-report.generated.js +3 -0
  331. package/lib-esm/schemas/shield-information-barrier-report.generated.js.map +1 -0
  332. package/lib-esm/schemas/shield-information-barrier-reports.generated.d.ts +26 -0
  333. package/lib-esm/schemas/shield-information-barrier-reports.generated.js +3 -0
  334. package/lib-esm/schemas/shield-information-barrier-reports.generated.js.map +1 -0
  335. package/lib-esm/schemas/shield-information-barrier-segment-member-base.generated.d.ts +19 -0
  336. package/lib-esm/schemas/shield-information-barrier-segment-member-base.generated.js +3 -0
  337. package/lib-esm/schemas/shield-information-barrier-segment-member-base.generated.js.map +1 -0
  338. package/lib-esm/schemas/shield-information-barrier-segment-member-mini.generated.d.ts +13 -0
  339. package/lib-esm/schemas/shield-information-barrier-segment-member-mini.generated.js +3 -0
  340. package/lib-esm/schemas/shield-information-barrier-segment-member-mini.generated.js.map +1 -0
  341. package/lib-esm/schemas/shield-information-barrier-segment-member.generated.d.ts +39 -0
  342. package/lib-esm/schemas/shield-information-barrier-segment-member.generated.js +3 -0
  343. package/lib-esm/schemas/shield-information-barrier-segment-member.generated.js.map +1 -0
  344. package/lib-esm/schemas/shield-information-barrier-segment-members.generated.d.ts +26 -0
  345. package/lib-esm/schemas/shield-information-barrier-segment-members.generated.js +3 -0
  346. package/lib-esm/schemas/shield-information-barrier-segment-members.generated.js.map +1 -0
  347. package/lib-esm/schemas/shield-information-barrier-segment-restriction-base.generated.d.ts +20 -0
  348. package/lib-esm/schemas/shield-information-barrier-segment-restriction-base.generated.js +3 -0
  349. package/lib-esm/schemas/shield-information-barrier-segment-restriction-base.generated.js.map +1 -0
  350. package/lib-esm/schemas/shield-information-barrier-segment-restriction-mini.generated.d.ts +20 -0
  351. package/lib-esm/schemas/shield-information-barrier-segment-restriction-mini.generated.js +3 -0
  352. package/lib-esm/schemas/shield-information-barrier-segment-restriction-mini.generated.js.map +1 -0
  353. package/lib-esm/schemas/shield-information-barrier-segment-restriction.generated.d.ts +33 -0
  354. package/lib-esm/schemas/shield-information-barrier-segment-restriction.generated.js +3 -0
  355. package/lib-esm/schemas/shield-information-barrier-segment-restriction.generated.js.map +1 -0
  356. package/lib-esm/schemas/shield-information-barrier-segment-restrictions.generated.d.ts +26 -0
  357. package/lib-esm/schemas/shield-information-barrier-segment-restrictions.generated.js +3 -0
  358. package/lib-esm/schemas/shield-information-barrier-segment-restrictions.generated.js.map +1 -0
  359. package/lib-esm/schemas/shield-information-barrier-segment.generated.d.ts +50 -0
  360. package/lib-esm/schemas/shield-information-barrier-segment.generated.js +3 -0
  361. package/lib-esm/schemas/shield-information-barrier-segment.generated.js.map +1 -0
  362. package/lib-esm/schemas/shield-information-barrier-segments.generated.d.ts +26 -0
  363. package/lib-esm/schemas/shield-information-barrier-segments.generated.js +3 -0
  364. package/lib-esm/schemas/shield-information-barrier-segments.generated.js.map +1 -0
  365. package/lib-esm/schemas/shield-information-barrier.generated.d.ts +56 -0
  366. package/lib-esm/schemas/shield-information-barrier.generated.js +3 -0
  367. package/lib-esm/schemas/shield-information-barrier.generated.js.map +1 -0
  368. package/lib-esm/schemas/shield-information-barriers.generated.d.ts +25 -0
  369. package/lib-esm/schemas/shield-information-barriers.generated.js +3 -0
  370. package/lib-esm/schemas/shield-information-barriers.generated.js.map +1 -0
  371. package/lib-esm/schemas/sign-request-base.generated.d.ts +78 -0
  372. package/lib-esm/schemas/sign-request-base.generated.js +3 -0
  373. package/lib-esm/schemas/sign-request-base.generated.js.map +1 -0
  374. package/lib-esm/schemas/sign-request-create-request.generated.d.ts +39 -0
  375. package/lib-esm/schemas/sign-request-create-request.generated.js +3 -0
  376. package/lib-esm/schemas/sign-request-create-request.generated.js.map +1 -0
  377. package/lib-esm/schemas/sign-request-create-signer.generated.d.ts +95 -0
  378. package/lib-esm/schemas/sign-request-create-signer.generated.js +3 -0
  379. package/lib-esm/schemas/sign-request-create-signer.generated.js.map +1 -0
  380. package/lib-esm/schemas/sign-request-prefill-tag.generated.d.ts +28 -0
  381. package/lib-esm/schemas/sign-request-prefill-tag.generated.js +3 -0
  382. package/lib-esm/schemas/sign-request-prefill-tag.generated.js.map +1 -0
  383. package/lib-esm/schemas/sign-request-signer-input.generated.d.ts +28 -0
  384. package/lib-esm/schemas/sign-request-signer-input.generated.js +3 -0
  385. package/lib-esm/schemas/sign-request-signer-input.generated.js.map +1 -0
  386. package/lib-esm/schemas/sign-request-signer.generated.d.ts +34 -0
  387. package/lib-esm/schemas/sign-request-signer.generated.js +3 -0
  388. package/lib-esm/schemas/sign-request-signer.generated.js.map +1 -0
  389. package/lib-esm/schemas/sign-request.generated.d.ts +72 -0
  390. package/lib-esm/schemas/sign-request.generated.js +3 -0
  391. package/lib-esm/schemas/sign-request.generated.js.map +1 -0
  392. package/lib-esm/schemas/sign-requests.generated.d.ts +25 -0
  393. package/lib-esm/schemas/sign-requests.generated.js +3 -0
  394. package/lib-esm/schemas/sign-requests.generated.js.map +1 -0
  395. package/lib-esm/schemas/sign-template.generated.d.ts +94 -0
  396. package/lib-esm/schemas/sign-template.generated.js +3 -0
  397. package/lib-esm/schemas/sign-template.generated.js.map +1 -0
  398. package/lib-esm/schemas/sign-templates.generated.d.ts +30 -0
  399. package/lib-esm/schemas/sign-templates.generated.js +3 -0
  400. package/lib-esm/schemas/sign-templates.generated.js.map +1 -0
  401. package/lib-esm/schemas/template-signer-input.generated.d.ts +61 -0
  402. package/lib-esm/schemas/template-signer-input.generated.js +3 -0
  403. package/lib-esm/schemas/template-signer-input.generated.js.map +1 -0
  404. package/lib-esm/schemas/template-signer.generated.d.ts +43 -0
  405. package/lib-esm/schemas/template-signer.generated.js +3 -0
  406. package/lib-esm/schemas/template-signer.generated.js.map +1 -0
  407. package/lib-esm/schemas/user-base.generated.d.ts +18 -0
  408. package/lib-esm/schemas/user-base.generated.js +3 -0
  409. package/lib-esm/schemas/user-base.generated.js.map +1 -0
  410. package/lib-esm/schemas/user-integration-mappings.d.ts +19 -0
  411. package/lib-esm/schemas/user-integration-mappings.js +3 -0
  412. package/lib-esm/schemas/user-integration-mappings.js.map +1 -0
  413. package/lib-esm/schemas/user-mini.d.ts +6 -0
  414. package/lib-esm/schemas/user-mini.js +3 -0
  415. package/lib-esm/schemas/user-mini.js.map +1 -0
  416. package/lib-esm/sessions/app-auth-session.d.ts +92 -0
  417. package/lib-esm/sessions/app-auth-session.js +176 -0
  418. package/lib-esm/sessions/app-auth-session.js.map +1 -0
  419. package/lib-esm/sessions/basic-session.d.ts +55 -0
  420. package/lib-esm/sessions/basic-session.js +62 -0
  421. package/lib-esm/sessions/basic-session.js.map +1 -0
  422. package/lib-esm/sessions/ccg-session.d.ts +72 -0
  423. package/lib-esm/sessions/ccg-session.js +111 -0
  424. package/lib-esm/sessions/ccg-session.js.map +1 -0
  425. package/lib-esm/sessions/persistent-session.d.ts +96 -0
  426. package/lib-esm/sessions/persistent-session.js +234 -0
  427. package/lib-esm/sessions/persistent-session.js.map +1 -0
  428. package/lib-esm/token-manager.d.ts +191 -0
  429. package/lib-esm/token-manager.js +453 -0
  430. package/lib-esm/token-manager.js.map +1 -0
  431. package/lib-esm/util/config.d.ts +85 -0
  432. package/lib-esm/util/config.js +212 -0
  433. package/lib-esm/util/config.js.map +1 -0
  434. package/lib-esm/util/errors.d.ts +50 -0
  435. package/lib-esm/util/errors.js +176 -0
  436. package/lib-esm/util/errors.js.map +1 -0
  437. package/lib-esm/util/exponential-backoff.d.ts +11 -0
  438. package/lib-esm/util/exponential-backoff.js +17 -0
  439. package/lib-esm/util/exponential-backoff.js.map +1 -0
  440. package/lib-esm/util/paging-iterator.d.ts +53 -0
  441. package/lib-esm/util/paging-iterator.js +247 -0
  442. package/lib-esm/util/paging-iterator.js.map +1 -0
  443. package/lib-esm/util/serializable.d.ts +10 -0
  444. package/lib-esm/util/serializable.js +17 -0
  445. package/lib-esm/util/serializable.js.map +1 -0
  446. package/lib-esm/util/url-path.d.ts +16 -0
  447. package/lib-esm/util/url-path.js +36 -0
  448. package/lib-esm/util/url-path.js.map +1 -0
  449. package/package.json +33 -28
@@ -0,0 +1,191 @@
1
+ /**
2
+ * @fileoverview Token Manager
3
+ */
4
+ import Promise from 'bluebird';
5
+ import APIRequestManager from './api-request-manager';
6
+ type Config = Record<string, any>;
7
+ /**
8
+ * Token request options. Set by the consumer to add/modify the params sent to the
9
+ * request.
10
+ *
11
+ * @typedef {Object} TokenRequestOptions
12
+ * @property {string} [ip] The IP Address of the requesting user. This IP will be reflected in authentication
13
+ * notification emails sent to your users on login. Defaults to the IP address of the
14
+ * server requesting the tokens.
15
+ */
16
+ type TokenRequestOptions = {
17
+ ip?: string;
18
+ };
19
+ /**
20
+ * Parameters for creating a token using a Box shared link via token exchange
21
+ * @typedef {Object} SharedLinkParams
22
+ * @property {string} url Shared link URL
23
+ */
24
+ type SharedLinkParams = {
25
+ url: string;
26
+ };
27
+ /**
28
+ * Parameters for creating an actor token via token exchange
29
+ * @typedef {Object} ActorParams
30
+ * @property {string} id The external identifier for the actor
31
+ * @property {string} name The display name of the actor
32
+ */
33
+ type ActorParams = {
34
+ id: string;
35
+ name: string;
36
+ };
37
+ /**
38
+ * An object representing all token information for a single Box user.
39
+ *
40
+ * @typedef {Object} TokenInfo
41
+ * @property {string} accessToken The API access token. Used to authenticate API requests to a certain
42
+ * user and/or application.
43
+ * @property {int} acquiredAtMS The time that the tokens were acquired.
44
+ * @property {int} accessTokenTTLMS The TTL of the access token. Can be used with acquiredAtMS to
45
+ * calculate if the current access token has expired.
46
+ * @property {string} [refreshToken] The API refresh token is a Longer-lasting than an access token, and can
47
+ * be used to gain a new access token if the current access token becomes
48
+ * expired. Grants like the 'client credentials' grant don't return a
49
+ * refresh token, and have no refresh capabilities.
50
+ */
51
+ type TokenInfo = {
52
+ accessToken: string;
53
+ acquiredAtMS: number;
54
+ accessTokenTTLMS: number;
55
+ refreshToken?: string;
56
+ };
57
+ /**
58
+ * Manager for API access abd refresh tokens
59
+ *
60
+ * @param {Config} config The config object
61
+ * @param {APIRequestManager} requestManager The API Request Manager
62
+ * @constructor
63
+ */
64
+ declare class TokenManager {
65
+ config: Config;
66
+ requestManager: APIRequestManager;
67
+ oauthBaseURL: string;
68
+ constructor(config: Config, requestManager: APIRequestManager);
69
+ /**
70
+ * Given a TokenInfo object, returns whether its access token is expired. An access token is considered
71
+ * expired once its TTL surpasses the current time outside of the given buffer. This is a public method so
72
+ * that other modules may check the validity of their tokens.
73
+ *
74
+ * @param {TokenInfo} tokenInfo the token info to be written
75
+ * @param {int} [bufferMS] An optional buffer we'd like to test against. The greater this buffer, the more aggressively
76
+ * we'll call a token invalid.
77
+ * @returns {boolean} True if token is valid outside of buffer, otherwise false
78
+ */
79
+ isAccessTokenValid(tokenInfo: TokenInfo, bufferMS?: number): boolean;
80
+ /**
81
+ * Acquires OAuth2 tokens using a grant type (authorization_code, password, refresh_token)
82
+ *
83
+ * @param {Object} formParams - should contain all params expected by Box OAuth2 token endpoint
84
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant, null for default behavior
85
+ * @returns {Promise<TokenInfo>} Promise resolving to the token info
86
+ * @private
87
+ */
88
+ getTokens(formParams: Record<string, any>, options?: TokenRequestOptions | null): Promise<{
89
+ accessToken: any;
90
+ refreshToken: any;
91
+ accessTokenTTLMS: number;
92
+ acquiredAtMS: number;
93
+ }>;
94
+ /**
95
+ * Acquires token info using an authorization code
96
+ *
97
+ * @param {string} authorizationCode - authorization code issued by Box
98
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
99
+ * @returns {Promise<TokenInfo>} Promise resolving to the token info
100
+ */
101
+ getTokensAuthorizationCodeGrant(authorizationCode: string, options?: TokenRequestOptions): Promise<{
102
+ accessToken: any;
103
+ refreshToken: any;
104
+ accessTokenTTLMS: number;
105
+ acquiredAtMS: number;
106
+ }>;
107
+ /**
108
+ * Acquires token info using the client credentials grant.
109
+ *
110
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
111
+ * @returns {Promise<TokenInfo>} Promise resolving to the token info
112
+ */
113
+ getTokensClientCredentialsGrant(options?: TokenRequestOptions): Promise<{
114
+ accessToken: any;
115
+ refreshToken: any;
116
+ accessTokenTTLMS: number;
117
+ acquiredAtMS: number;
118
+ }>;
119
+ /**
120
+ * Refreshes the access and refresh tokens for a given refresh token.
121
+ *
122
+ * @param {string} refreshToken - A valid OAuth refresh token
123
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
124
+ * @returns {Promise<TokenInfo>} Promise resolving to the token info
125
+ */
126
+ getTokensRefreshGrant(refreshToken: string, options?: TokenRequestOptions): Promise<{
127
+ accessToken: any;
128
+ refreshToken: any;
129
+ accessTokenTTLMS: number;
130
+ acquiredAtMS: number;
131
+ }>;
132
+ /**
133
+ * Gets tokens for enterprise administration of app users
134
+ * @param {string} type The type of token to create, "user" or "enterprise"
135
+ * @param {string} id The ID of the enterprise to generate a token for
136
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
137
+ * @returns {Promise<TokenInfo>} Promise resolving to the token info
138
+ */
139
+ getTokensJWTGrant(type: string, id: string, options?: TokenRequestOptions): Promise<any>;
140
+ /**
141
+ * Attempt a retry if possible and create a new JTI claim. If the request hasn't exceeded it's maximum number of retries,
142
+ * re-execute the request (after the retry interval). Otherwise, propagate a new error.
143
+ *
144
+ * @param {Object} claims - JTI claims object
145
+ * @param {Object} [jwtOptions] - JWT options for the signature
146
+ * @param {Object} keyParams - Key JWT parameters object that contains the private key and the passphrase
147
+ * @param {Object} params - Should contain all params expected by Box OAuth2 token endpoint
148
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
149
+ * @param {Error} error - Error from the previous JWT request
150
+ * @param {int} numRetries - Number of retries attempted
151
+ * @returns {Promise<TokenInfo>} Promise resolving to the token info
152
+ */
153
+ retryJWTGrant(claims: any, jwtOptions: any, keyParams: any, params: any, options: TokenRequestOptions | undefined, error: any, numRetries: number): any;
154
+ /**
155
+ * Exchange a valid access token for one with a lower scope, or delegated to
156
+ * an external user identifier.
157
+ *
158
+ * @param {string} accessToken - The valid access token to exchange
159
+ * @param {string|string[]} scopes - The scope(s) of the new access token
160
+ * @param {string} [resource] - The absolute URL of an API resource to restrict the new token to
161
+ * @param {Object} [options] - Optional parameters
162
+ * @param {TokenRequestOptions} [options.tokenRequestOptions] - Sets optional behavior for the token grant
163
+ * @param {ActorParams} [options.actor] - Optional actor parameters for creating annotator tokens
164
+ * @param {SharedLinkParams} [options.sharedLink] - Optional shared link parameters for creating tokens using shared links
165
+ * @returns {Promise<TokenInfo>} Promise resolving to the new token info
166
+ */
167
+ exchangeToken(accessToken: string, scopes: string | string[], resource?: string, options?: {
168
+ tokenRequestOptions?: TokenRequestOptions;
169
+ actor?: ActorParams;
170
+ sharedLink?: SharedLinkParams;
171
+ }): Promise<{
172
+ accessToken: any;
173
+ refreshToken: any;
174
+ accessTokenTTLMS: number;
175
+ acquiredAtMS: number;
176
+ }>;
177
+ /**
178
+ * Revokes a token pair associated with a given access or refresh token.
179
+ *
180
+ * @param {string} token - A valid access or refresh token to revoke
181
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
182
+ * @returns {Promise} Promise resolving if the revoke succeeds
183
+ */
184
+ revokeTokens(token: string, options?: TokenRequestOptions): Promise<unknown>;
185
+ }
186
+ /**
187
+ * Provides interactions with Box OAuth2 tokening system.
188
+ *
189
+ * @module box-node-sdk/lib/token-manager
190
+ */
191
+ export = TokenManager;
@@ -0,0 +1,453 @@
1
+ "use strict";
2
+ /**
3
+ * @fileoverview Token Manager
4
+ */
5
+ var __importDefault = (this && this.__importDefault) || function (mod) {
6
+ return (mod && mod.__esModule) ? mod : { "default": mod };
7
+ };
8
+ // ------------------------------------------------------------------------------
9
+ // Requirements
10
+ // ------------------------------------------------------------------------------
11
+ const bluebird_1 = __importDefault(require("bluebird"));
12
+ const http_status_1 = __importDefault(require("http-status"));
13
+ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
14
+ const uuid_1 = require("uuid");
15
+ const errors_1 = __importDefault(require("./util/errors"));
16
+ const exponential_backoff_1 = __importDefault(require("./util/exponential-backoff"));
17
+ /**
18
+ * Determines whether a JWT auth error can be retried
19
+ * @param {Error} err The JWT auth error
20
+ * @returns {boolean} True if the error is retryable
21
+ */
22
+ function isJWTAuthErrorRetryable(err /* FIXME */) {
23
+ if (err.authExpired &&
24
+ err.response.headers.date &&
25
+ (err.response.body.error_description.indexOf('exp') > -1 ||
26
+ err.response.body.error_description.indexOf('jti') > -1)) {
27
+ return true;
28
+ }
29
+ else if (err.statusCode === 429 || err.statusCode >= 500) {
30
+ return true;
31
+ }
32
+ return false;
33
+ }
34
+ // ------------------------------------------------------------------------------
35
+ // Constants
36
+ // ------------------------------------------------------------------------------
37
+ /**
38
+ * Collection of grant types that can be used to acquire tokens via OAuth2
39
+ *
40
+ * @readonly
41
+ * @enum {string}
42
+ */
43
+ var grantTypes = {
44
+ AUTHORIZATION_CODE: 'authorization_code',
45
+ REFRESH_TOKEN: 'refresh_token',
46
+ CLIENT_CREDENTIALS: 'client_credentials',
47
+ JWT: 'urn:ietf:params:oauth:grant-type:jwt-bearer',
48
+ TOKEN_EXCHANGE: 'urn:ietf:params:oauth:grant-type:token-exchange',
49
+ };
50
+ /**
51
+ * Collection of paths to interact with Box OAuth2 tokening system
52
+ *
53
+ * @readonly
54
+ * @enum {string}
55
+ */
56
+ var tokenPaths;
57
+ (function (tokenPaths) {
58
+ tokenPaths["ROOT"] = "/oauth2";
59
+ tokenPaths["GET"] = "/token";
60
+ tokenPaths["REVOKE"] = "/revoke";
61
+ })(tokenPaths || (tokenPaths = {}));
62
+ // Timer used to track elapsed time starting with executing an async request and ending with emitting the response.
63
+ var asyncRequestTimer /* FIXME */;
64
+ // The XFF header label - Used to give the API better information for uploads, rate-limiting, etc.
65
+ const HEADER_XFF = 'X-Forwarded-For';
66
+ const ACCESS_TOKEN_TYPE = 'urn:ietf:params:oauth:token-type:access_token';
67
+ const ACTOR_TOKEN_TYPE = 'urn:ietf:params:oauth:token-type:id_token';
68
+ const BOX_JWT_AUDIENCE = 'https://api.box.com/oauth2/token';
69
+ // ------------------------------------------------------------------------------
70
+ // Private
71
+ // ------------------------------------------------------------------------------
72
+ /**
73
+ * Parse the response body to create a new TokenInfo object.
74
+ *
75
+ * @param {Object} grantResponseBody - (Request lib) response body containing granted token info from API
76
+ * @returns {TokenInfo} A TokenInfo object.
77
+ * @private
78
+ */
79
+ function getTokensFromGrantResponse(grantResponseBody /* FIXME */) {
80
+ return {
81
+ // Set the access token & refresh token (if passed)
82
+ accessToken: grantResponseBody.access_token,
83
+ refreshToken: grantResponseBody.refresh_token,
84
+ // Box API sends back expires_in in seconds, we convert to ms for consistency of keeping all time in ms
85
+ accessTokenTTLMS: parseInt(grantResponseBody.expires_in, 10) * 1000,
86
+ acquiredAtMS: Date.now(),
87
+ };
88
+ }
89
+ /**
90
+ * Determines if a given string could represent an authorization code or token.
91
+ *
92
+ * @param {string} codeOrToken The code or token to check.
93
+ * @returns {boolean} True if codeOrToken is valid, false if not.
94
+ * @private
95
+ */
96
+ function isValidCodeOrToken(codeOrToken) {
97
+ return typeof codeOrToken === 'string' && codeOrToken.length > 0;
98
+ }
99
+ /**
100
+ * Determines if a token grant response is valid
101
+ *
102
+ * @param {string} grantType the type of token grant
103
+ * @param {Object} responseBody the body of the response to check
104
+ * @returns {boolean} True if response body has expected fields, false if not.
105
+ * @private
106
+ */
107
+ function isValidTokenResponse(grantType, responseBody /* FIXME */) {
108
+ if (!isValidCodeOrToken(responseBody.access_token)) {
109
+ return false;
110
+ }
111
+ if (typeof responseBody.expires_in !== 'number') {
112
+ return false;
113
+ }
114
+ // Check the refresh_token for certain types of grants
115
+ if (grantType === 'authorization_code' || grantType === 'refresh_token') {
116
+ if (!isValidCodeOrToken(responseBody.refresh_token)) {
117
+ return false;
118
+ }
119
+ }
120
+ return true;
121
+ }
122
+ // ------------------------------------------------------------------------------
123
+ // Public
124
+ // ------------------------------------------------------------------------------
125
+ /**
126
+ * Manager for API access abd refresh tokens
127
+ *
128
+ * @param {Config} config The config object
129
+ * @param {APIRequestManager} requestManager The API Request Manager
130
+ * @constructor
131
+ */
132
+ class TokenManager {
133
+ constructor(config, requestManager) {
134
+ this.config = config;
135
+ this.oauthBaseURL = config.apiRootURL + tokenPaths.ROOT;
136
+ this.requestManager = requestManager;
137
+ }
138
+ /**
139
+ * Given a TokenInfo object, returns whether its access token is expired. An access token is considered
140
+ * expired once its TTL surpasses the current time outside of the given buffer. This is a public method so
141
+ * that other modules may check the validity of their tokens.
142
+ *
143
+ * @param {TokenInfo} tokenInfo the token info to be written
144
+ * @param {int} [bufferMS] An optional buffer we'd like to test against. The greater this buffer, the more aggressively
145
+ * we'll call a token invalid.
146
+ * @returns {boolean} True if token is valid outside of buffer, otherwise false
147
+ */
148
+ isAccessTokenValid(tokenInfo, bufferMS) {
149
+ if (typeof tokenInfo.acquiredAtMS === 'undefined' ||
150
+ typeof tokenInfo.accessTokenTTLMS === 'undefined') {
151
+ return false;
152
+ }
153
+ bufferMS = bufferMS || 0;
154
+ var expireTime = tokenInfo.acquiredAtMS + tokenInfo.accessTokenTTLMS - bufferMS;
155
+ return expireTime > Date.now();
156
+ }
157
+ /**
158
+ * Acquires OAuth2 tokens using a grant type (authorization_code, password, refresh_token)
159
+ *
160
+ * @param {Object} formParams - should contain all params expected by Box OAuth2 token endpoint
161
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant, null for default behavior
162
+ * @returns {Promise<TokenInfo>} Promise resolving to the token info
163
+ * @private
164
+ */
165
+ getTokens(formParams, options) {
166
+ var params = {
167
+ method: 'POST',
168
+ url: this.oauthBaseURL + tokenPaths.GET,
169
+ headers: {},
170
+ form: formParams,
171
+ };
172
+ options = options || {};
173
+ // add in app-specific id and secret to auth with Box
174
+ params.form.client_id = this.config.clientID;
175
+ params.form.client_secret = this.config.clientSecret;
176
+ if (options.ip) {
177
+ params.headers[HEADER_XFF] = options.ip;
178
+ }
179
+ return this.requestManager
180
+ .makeRequest(params)
181
+ .then((response /* FIXME */) => {
182
+ // Response Error: The API is telling us that we attempted an invalid token grant. This
183
+ // means that our refresh token or auth code has exipred, so propagate an "Expired Tokens"
184
+ // error.
185
+ if (response.body &&
186
+ response.body.error &&
187
+ response.body.error === 'invalid_grant') {
188
+ var errDescription = response.body.error_description;
189
+ var message = errDescription
190
+ ? `Auth Error: ${errDescription}`
191
+ : undefined;
192
+ throw errors_1.default.buildAuthError(response, message);
193
+ }
194
+ // Unexpected Response: If the token request couldn't get a valid response, then we're
195
+ // out of options. Build an "Unexpected Response" error and propagate it out for the
196
+ // consumer to handle.
197
+ if (response.statusCode !== http_status_1.default.OK ||
198
+ response.body instanceof Buffer) {
199
+ throw errors_1.default.buildUnexpectedResponseError(response);
200
+ }
201
+ // Check to see if token response is valid in case the API returns us a 200 with a malformed token
202
+ if (!isValidTokenResponse(formParams.grant_type, response.body)) {
203
+ throw errors_1.default.buildResponseError(response, 'Token format from response invalid');
204
+ }
205
+ // Got valid token response. Parse out the TokenInfo and propagate it back.
206
+ return getTokensFromGrantResponse(response.body);
207
+ });
208
+ }
209
+ /**
210
+ * Acquires token info using an authorization code
211
+ *
212
+ * @param {string} authorizationCode - authorization code issued by Box
213
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
214
+ * @returns {Promise<TokenInfo>} Promise resolving to the token info
215
+ */
216
+ getTokensAuthorizationCodeGrant(authorizationCode, options) {
217
+ if (!isValidCodeOrToken(authorizationCode)) {
218
+ return bluebird_1.default.reject(new Error('Invalid authorization code.'));
219
+ }
220
+ var params = {
221
+ grant_type: grantTypes.AUTHORIZATION_CODE,
222
+ code: authorizationCode,
223
+ };
224
+ return this.getTokens(params, options);
225
+ }
226
+ /**
227
+ * Acquires token info using the client credentials grant.
228
+ *
229
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
230
+ * @returns {Promise<TokenInfo>} Promise resolving to the token info
231
+ */
232
+ getTokensClientCredentialsGrant(options) {
233
+ var params = {
234
+ grant_type: grantTypes.CLIENT_CREDENTIALS,
235
+ box_subject_type: this.config.boxSubjectType,
236
+ box_subject_id: this.config.boxSubjectId,
237
+ };
238
+ return this.getTokens(params, options);
239
+ }
240
+ /**
241
+ * Refreshes the access and refresh tokens for a given refresh token.
242
+ *
243
+ * @param {string} refreshToken - A valid OAuth refresh token
244
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
245
+ * @returns {Promise<TokenInfo>} Promise resolving to the token info
246
+ */
247
+ getTokensRefreshGrant(refreshToken, options) {
248
+ if (!isValidCodeOrToken(refreshToken)) {
249
+ return bluebird_1.default.reject(new Error('Invalid refresh token.'));
250
+ }
251
+ var params = {
252
+ grant_type: grantTypes.REFRESH_TOKEN,
253
+ refresh_token: refreshToken,
254
+ };
255
+ return this.getTokens(params, options);
256
+ }
257
+ /**
258
+ * Gets tokens for enterprise administration of app users
259
+ * @param {string} type The type of token to create, "user" or "enterprise"
260
+ * @param {string} id The ID of the enterprise to generate a token for
261
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
262
+ * @returns {Promise<TokenInfo>} Promise resolving to the token info
263
+ */
264
+ getTokensJWTGrant(type, id, options) {
265
+ if (!this.config.appAuth || !this.config.appAuth.keyID) {
266
+ return bluebird_1.default.reject(new Error('Must provide app auth configuration to use JWT Grant'));
267
+ }
268
+ var claims = {
269
+ exp: Math.floor(Date.now() / 1000) + this.config.appAuth.expirationTime,
270
+ box_sub_type: type,
271
+ };
272
+ var jwtOptions = {
273
+ algorithm: this.config.appAuth.algorithm,
274
+ audience: BOX_JWT_AUDIENCE,
275
+ subject: id,
276
+ issuer: this.config.clientID,
277
+ jwtid: (0, uuid_1.v4)(),
278
+ noTimestamp: !this.config.appAuth.verifyTimestamp,
279
+ keyid: this.config.appAuth.keyID,
280
+ };
281
+ var keyParams = {
282
+ key: this.config.appAuth.privateKey,
283
+ passphrase: this.config.appAuth.passphrase,
284
+ };
285
+ var assertion;
286
+ try {
287
+ assertion = jsonwebtoken_1.default.sign(claims, keyParams, jwtOptions);
288
+ }
289
+ catch (jwtErr) {
290
+ return bluebird_1.default.reject(jwtErr);
291
+ }
292
+ var params = {
293
+ grant_type: grantTypes.JWT,
294
+ assertion,
295
+ };
296
+ // Start the request timer immediately before executing the async request
297
+ asyncRequestTimer = process.hrtime();
298
+ return this.getTokens(params, options).catch((err) => this.retryJWTGrant(claims, jwtOptions, keyParams, params, options, err, 0));
299
+ }
300
+ /**
301
+ * Attempt a retry if possible and create a new JTI claim. If the request hasn't exceeded it's maximum number of retries,
302
+ * re-execute the request (after the retry interval). Otherwise, propagate a new error.
303
+ *
304
+ * @param {Object} claims - JTI claims object
305
+ * @param {Object} [jwtOptions] - JWT options for the signature
306
+ * @param {Object} keyParams - Key JWT parameters object that contains the private key and the passphrase
307
+ * @param {Object} params - Should contain all params expected by Box OAuth2 token endpoint
308
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
309
+ * @param {Error} error - Error from the previous JWT request
310
+ * @param {int} numRetries - Number of retries attempted
311
+ * @returns {Promise<TokenInfo>} Promise resolving to the token info
312
+ */
313
+ // eslint-disable-next-line max-params
314
+ retryJWTGrant(claims /* FIXME */, jwtOptions /* FIXME */, keyParams /* FIXME */, params /* FIXME */, options, error /* FIXME */, numRetries) {
315
+ if (numRetries < this.config.numMaxRetries &&
316
+ isJWTAuthErrorRetryable(error)) {
317
+ var retryTimeoutinSeconds;
318
+ numRetries += 1;
319
+ // If the retry strategy is defined, then use it to determine the time (in ms) until the next retry or to
320
+ // propagate an error to the user.
321
+ if (this.config.retryStrategy) {
322
+ // Get the total elapsed time so far since the request was executed
323
+ var totalElapsedTime = process.hrtime(asyncRequestTimer);
324
+ var totalElapsedTimeMS = totalElapsedTime[0] * 1000 + totalElapsedTime[1] / 1000000;
325
+ var retryOptions = {
326
+ error,
327
+ numRetryAttempts: numRetries,
328
+ numMaxRetries: this.config.numMaxRetries,
329
+ retryIntervalMS: this.config.retryIntervalMS,
330
+ totalElapsedTimeMS,
331
+ };
332
+ retryTimeoutinSeconds = this.config.retryStrategy(retryOptions);
333
+ // If the retry strategy doesn't return a number/time in ms, then propagate the response error to the user.
334
+ // However, if the retry strategy returns its own error, this will be propagated to the user instead.
335
+ if (typeof retryTimeoutinSeconds !== 'number') {
336
+ if (retryTimeoutinSeconds instanceof Error) {
337
+ error = retryTimeoutinSeconds;
338
+ }
339
+ throw error;
340
+ }
341
+ }
342
+ else if (error.hasOwnProperty('response') &&
343
+ error.response.hasOwnProperty('headers') &&
344
+ error.response.headers.hasOwnProperty('retry-after')) {
345
+ retryTimeoutinSeconds = error.response.headers['retry-after'];
346
+ }
347
+ else {
348
+ retryTimeoutinSeconds = Math.ceil((0, exponential_backoff_1.default)(numRetries, this.config.retryIntervalMS) / 1000);
349
+ }
350
+ var time = Math.floor(Date.now() / 1000);
351
+ if (error.response.headers.date) {
352
+ time = Math.floor(Date.parse(error.response.headers.date) / 1000);
353
+ }
354
+ // Add length of retry timeout to current expiration time to calculate the expiration time for the JTI claim.
355
+ claims.exp = Math.ceil(time + this.config.appAuth.expirationTime + retryTimeoutinSeconds);
356
+ jwtOptions.jwtid = (0, uuid_1.v4)();
357
+ try {
358
+ params.assertion = jsonwebtoken_1.default.sign(claims, keyParams, jwtOptions);
359
+ }
360
+ catch (jwtErr) {
361
+ throw jwtErr;
362
+ }
363
+ return bluebird_1.default.delay(retryTimeoutinSeconds).then(() => {
364
+ // Start the request timer immediately before executing the async request
365
+ asyncRequestTimer = process.hrtime();
366
+ return this.getTokens(params, options).catch((err) => this.retryJWTGrant(claims, jwtOptions, keyParams, params, options, err, numRetries));
367
+ });
368
+ }
369
+ else if (numRetries >= this.config.numMaxRetries) {
370
+ error.maxRetriesExceeded = true;
371
+ }
372
+ throw error;
373
+ }
374
+ /**
375
+ * Exchange a valid access token for one with a lower scope, or delegated to
376
+ * an external user identifier.
377
+ *
378
+ * @param {string} accessToken - The valid access token to exchange
379
+ * @param {string|string[]} scopes - The scope(s) of the new access token
380
+ * @param {string} [resource] - The absolute URL of an API resource to restrict the new token to
381
+ * @param {Object} [options] - Optional parameters
382
+ * @param {TokenRequestOptions} [options.tokenRequestOptions] - Sets optional behavior for the token grant
383
+ * @param {ActorParams} [options.actor] - Optional actor parameters for creating annotator tokens
384
+ * @param {SharedLinkParams} [options.sharedLink] - Optional shared link parameters for creating tokens using shared links
385
+ * @returns {Promise<TokenInfo>} Promise resolving to the new token info
386
+ */
387
+ exchangeToken(accessToken, scopes, resource, options) {
388
+ var params = {
389
+ grant_type: grantTypes.TOKEN_EXCHANGE,
390
+ subject_token_type: ACCESS_TOKEN_TYPE,
391
+ subject_token: accessToken,
392
+ scope: typeof scopes === 'string' ? scopes : scopes.join(' '),
393
+ };
394
+ if (resource) {
395
+ params.resource = resource;
396
+ }
397
+ if (options && options.sharedLink) {
398
+ params.box_shared_link = options.sharedLink.url;
399
+ }
400
+ if (options && options.actor) {
401
+ var payload = {
402
+ iss: this.config.clientID,
403
+ sub: options.actor.id,
404
+ aud: BOX_JWT_AUDIENCE,
405
+ box_sub_type: 'external',
406
+ name: options.actor.name,
407
+ };
408
+ var jwtOptions = {
409
+ algorithm: 'none',
410
+ expiresIn: '1m',
411
+ noTimestamp: true,
412
+ jwtid: (0, uuid_1.v4)(),
413
+ };
414
+ var token;
415
+ try {
416
+ token = jsonwebtoken_1.default.sign(payload, 'UNUSED', jwtOptions /* FIXME */);
417
+ }
418
+ catch (jwtError) {
419
+ return bluebird_1.default.reject(jwtError);
420
+ }
421
+ params.actor_token = token;
422
+ params.actor_token_type = ACTOR_TOKEN_TYPE;
423
+ }
424
+ return this.getTokens(params, options && options.tokenRequestOptions
425
+ ? options.tokenRequestOptions
426
+ : null);
427
+ }
428
+ /**
429
+ * Revokes a token pair associated with a given access or refresh token.
430
+ *
431
+ * @param {string} token - A valid access or refresh token to revoke
432
+ * @param {TokenRequestOptions} [options] - Sets optional behavior for the token grant
433
+ * @returns {Promise} Promise resolving if the revoke succeeds
434
+ */
435
+ revokeTokens(token, options) {
436
+ var params = {
437
+ method: 'POST',
438
+ url: this.oauthBaseURL + tokenPaths.REVOKE,
439
+ form: {
440
+ token,
441
+ client_id: this.config.clientID,
442
+ client_secret: this.config.clientSecret,
443
+ },
444
+ };
445
+ if (options && options.ip) {
446
+ params.headers = {};
447
+ params.headers[HEADER_XFF] = options.ip;
448
+ }
449
+ return this.requestManager.makeRequest(params);
450
+ }
451
+ }
452
+ module.exports = TokenManager;
453
+ //# sourceMappingURL=token-manager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-manager.js","sourceRoot":"","sources":["../src/token-manager.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;AAEH,iFAAiF;AACjF,eAA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