box-node-sdk 1.35.0 → 1.37.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 (126) hide show
  1. package/CHANGELOG.md +37 -2
  2. package/README.md +1 -1
  3. package/lib/api-request-manager.d.ts +38 -0
  4. package/lib/api-request-manager.js +48 -55
  5. package/lib/api-request-manager.js.map +1 -0
  6. package/lib/api-request.d.ts +141 -0
  7. package/lib/api-request.js +202 -281
  8. package/lib/api-request.js.map +1 -0
  9. package/lib/box-client.d.ts +269 -0
  10. package/lib/box-client.js +551 -713
  11. package/lib/box-client.js.map +1 -0
  12. package/lib/box-node-sdk.d.ts +216 -0
  13. package/lib/box-node-sdk.js +317 -352
  14. package/lib/box-node-sdk.js.map +1 -0
  15. package/lib/chunked-uploader.d.ts +129 -0
  16. package/lib/chunked-uploader.js +287 -358
  17. package/lib/chunked-uploader.js.map +1 -0
  18. package/lib/enterprise-event-stream.d.ts +82 -0
  19. package/lib/enterprise-event-stream.js +189 -203
  20. package/lib/enterprise-event-stream.js.map +1 -0
  21. package/lib/event-stream.d.ts +92 -0
  22. package/lib/event-stream.js +274 -302
  23. package/lib/event-stream.js.map +1 -0
  24. package/lib/managers/collaboration-allowlist.d.ts +137 -0
  25. package/lib/managers/collaboration-allowlist.js +200 -0
  26. package/lib/managers/collaboration-allowlist.js.map +1 -0
  27. package/lib/managers/collaboration-whitelist.d.ts +3 -0
  28. package/lib/managers/collaboration-whitelist.js +8 -222
  29. package/lib/managers/collaboration-whitelist.js.map +1 -0
  30. package/lib/managers/collaborations.d.ts +166 -0
  31. package/lib/managers/collaborations.js +225 -258
  32. package/lib/managers/collaborations.js.map +1 -0
  33. package/lib/managers/collections.d.ts +42 -0
  34. package/lib/managers/collections.js +45 -50
  35. package/lib/managers/collections.js.map +1 -0
  36. package/lib/managers/comments.d.ts +103 -0
  37. package/lib/managers/comments.js +158 -173
  38. package/lib/managers/comments.js.map +1 -0
  39. package/lib/managers/device-pins.d.ts +52 -0
  40. package/lib/managers/device-pins.js +75 -88
  41. package/lib/managers/device-pins.js.map +1 -0
  42. package/lib/managers/enterprise.d.ts +162 -0
  43. package/lib/managers/enterprise.js +168 -199
  44. package/lib/managers/enterprise.js.map +1 -0
  45. package/lib/managers/events.d.ts +177 -0
  46. package/lib/managers/events.js +230 -254
  47. package/lib/managers/events.js.map +1 -0
  48. package/lib/managers/files.d.ts +772 -0
  49. package/lib/managers/files.js +1400 -1602
  50. package/lib/managers/files.js.map +1 -0
  51. package/lib/managers/folders.d.ts +347 -0
  52. package/lib/managers/folders.js +551 -567
  53. package/lib/managers/folders.js.map +1 -0
  54. package/lib/managers/groups.d.ts +202 -0
  55. package/lib/managers/groups.js +238 -287
  56. package/lib/managers/groups.js.map +1 -0
  57. package/lib/managers/legal-hold-policies.d.ts +190 -0
  58. package/lib/managers/legal-hold-policies.js +228 -272
  59. package/lib/managers/legal-hold-policies.js.map +1 -0
  60. package/lib/managers/metadata.d.ts +228 -0
  61. package/lib/managers/metadata.js +265 -328
  62. package/lib/managers/metadata.js.map +1 -0
  63. package/lib/managers/recent-items.d.ts +38 -0
  64. package/lib/managers/recent-items.js +32 -39
  65. package/lib/managers/recent-items.js.map +1 -0
  66. package/lib/managers/retention-policies.d.ts +213 -0
  67. package/lib/managers/retention-policies.js +235 -281
  68. package/lib/managers/retention-policies.js.map +1 -0
  69. package/lib/managers/search.d.ts +82 -0
  70. package/lib/managers/search.js +68 -88
  71. package/lib/managers/search.js.map +1 -0
  72. package/lib/managers/shared-items.d.ts +33 -0
  73. package/lib/managers/shared-items.js +54 -62
  74. package/lib/managers/shared-items.js.map +1 -0
  75. package/lib/managers/storage-policies.d.ts +86 -0
  76. package/lib/managers/storage-policies.js +108 -142
  77. package/lib/managers/storage-policies.js.map +1 -0
  78. package/lib/managers/tasks.d.ts +161 -0
  79. package/lib/managers/tasks.js +219 -260
  80. package/lib/managers/tasks.js.map +1 -0
  81. package/lib/managers/terms-of-service.d.ts +161 -0
  82. package/lib/managers/terms-of-service.js +250 -273
  83. package/lib/managers/terms-of-service.js.map +1 -0
  84. package/lib/managers/trash.d.ts +30 -0
  85. package/lib/managers/trash.js +30 -41
  86. package/lib/managers/trash.js.map +1 -0
  87. package/lib/managers/users.d.ts +131 -0
  88. package/lib/managers/users.js +160 -203
  89. package/lib/managers/users.js.map +1 -0
  90. package/lib/managers/web-links.d.ts +127 -0
  91. package/lib/managers/web-links.js +183 -209
  92. package/lib/managers/web-links.js.map +1 -0
  93. package/lib/managers/webhooks.d.ts +166 -0
  94. package/lib/managers/webhooks.js +312 -305
  95. package/lib/managers/webhooks.js.map +1 -0
  96. package/lib/sessions/anonymous-session.d.ts +69 -0
  97. package/lib/sessions/anonymous-session.js +88 -102
  98. package/lib/sessions/anonymous-session.js.map +1 -0
  99. package/lib/sessions/app-auth-session.d.ts +92 -0
  100. package/lib/sessions/app-auth-session.js +140 -160
  101. package/lib/sessions/app-auth-session.js.map +1 -0
  102. package/lib/sessions/basic-session.d.ts +56 -0
  103. package/lib/sessions/basic-session.js +40 -50
  104. package/lib/sessions/basic-session.js.map +1 -0
  105. package/lib/sessions/persistent-session.d.ts +96 -0
  106. package/lib/sessions/persistent-session.js +191 -211
  107. package/lib/sessions/persistent-session.js.map +1 -0
  108. package/lib/token-manager.d.ts +191 -0
  109. package/lib/token-manager.js +390 -465
  110. package/lib/token-manager.js.map +1 -0
  111. package/lib/util/config.d.ts +86 -0
  112. package/lib/util/config.js +124 -152
  113. package/lib/util/config.js.map +1 -0
  114. package/lib/util/errors.d.ts +50 -0
  115. package/lib/util/errors.js +134 -145
  116. package/lib/util/errors.js.map +1 -0
  117. package/lib/util/exponential-backoff.d.ts +11 -0
  118. package/lib/util/exponential-backoff.js +10 -22
  119. package/lib/util/exponential-backoff.js.map +1 -0
  120. package/lib/util/paging-iterator.d.ts +53 -0
  121. package/lib/util/paging-iterator.js +202 -218
  122. package/lib/util/paging-iterator.js.map +1 -0
  123. package/lib/util/url-path.d.ts +16 -0
  124. package/lib/util/url-path.js +20 -35
  125. package/lib/util/url-path.js.map +1 -0
  126. package/package.json +24 -9
@@ -0,0 +1,166 @@
1
+ /**
2
+ * @fileoverview Manager for the Box Webhooks resource
3
+ */
4
+ import BoxClient from '../box-client';
5
+ /**
6
+ * A webhook trigger type constant
7
+ * @typedef {string} WebhookTriggerType
8
+ */
9
+ declare enum WebhookTriggerType {
10
+ FILE_UPLOADED = "FILE.UPLOADED",
11
+ FILE_PREVIEWED = "FILE.PREVIEWED",
12
+ FILE_DOWNLOADED = "FILE.DOWNLOADED",
13
+ FILE_TRASHED = "FILE.TRASHED",
14
+ FILE_DELETED = "FILE.DELETED",
15
+ FILE_RESTORED = "FILE.RESTORED",
16
+ FILE_COPIED = "FILE.COPIED",
17
+ FILE_MOVED = "FILE.MOVED",
18
+ FILE_LOCKED = "FILE.LOCKED",
19
+ FILE_UNLOCKED = "FILE.UNLOCKED",
20
+ FILE_RENAMED = "FILE.RENAMED",
21
+ COMMENT_CREATED = "COMMENT.CREATED",
22
+ COMMENT_UPDATED = "COMMENT.UPDATED",
23
+ COMMENT_DELETED = "COMMENT.DELETED",
24
+ TASK_ASSIGNMENT_CREATED = "TASK_ASSIGNMENT.CREATED",
25
+ TASK_ASSIGNMENT_UPDATED = "TASK_ASSIGNMENT.UPDATED",
26
+ METADATA_INSTANCE_CREATED = "METADATA_INSTANCE.CREATED",
27
+ METADATA_INSTANCE_UPDATED = "METADATA_INSTANCE.UPDATED",
28
+ METADATA_INSTANCE_DELETED = "METADATA_INSTANCE.DELETED",
29
+ FOLDER_CREATED = "FOLDER.CREATED",
30
+ FOLDER_DOWNLOADED = "FOLDER.DOWNLOADED",
31
+ FOLDER_RESTORED = "FOLDER.RESTORED",
32
+ FOLDER_DELETED = "FOLDER.DELETED",
33
+ FOLDER_COPIED = "FOLDER.COPIED",
34
+ FOLDER_MOVED = "FOLDER.MOVED",
35
+ FOLDER_TRASHED = "FOLDER.TRASHED",
36
+ FOLDER_RENAMED = "FOLDER.RENAMED",
37
+ WEBHOOK_DELETED = "WEBHOOK.DELETED",
38
+ COLLABORATION_CREATED = "COLLABORATION.CREATED",
39
+ COLLABORATION_ACCEPTED = "COLLABORATION.ACCEPTED",
40
+ COLLABORATION_REJECTED = "COLLABORATION.REJECTED",
41
+ COLLABORATION_REMOVED = "COLLABORATION.REMOVED",
42
+ COLLABORATION_UPDATED = "COLLABORATION.UPDATED",
43
+ SHARED_LINK_DELETED = "SHARED_LINK.DELETED",
44
+ SHARED_LINK_CREATED = "SHARED_LINK.CREATED",
45
+ SHARED_LINK_UPDATED = "SHARED_LINK.UPDATED"
46
+ }
47
+ /**
48
+ * Simple manager for interacting with all 'Webhooks' endpoints and actions.
49
+ *
50
+ * @param {BoxClient} client The Box API Client that is responsible for making calls to the API
51
+ * @constructor
52
+ */
53
+ declare class Webhooks {
54
+ /**
55
+ * Primary signature key to protect webhooks against attacks.
56
+ * @static
57
+ * @type {?string}
58
+ */
59
+ static primarySignatureKey: string | null;
60
+ /**
61
+ * Secondary signature key to protect webhooks against attacks.
62
+ * @static
63
+ * @type {?string}
64
+ */
65
+ static secondarySignatureKey: string | null;
66
+ /**
67
+ * Sets primary and secondary signatures that are used to verify the Webhooks messages
68
+ *
69
+ * @param {string} primaryKey - The primary signature to verify the message with
70
+ * @param {string} [secondaryKey] - The secondary signature to verify the message with
71
+ * @returns {void}
72
+ */
73
+ static setSignatureKeys(primaryKey: string, secondaryKey?: string): void;
74
+ /**
75
+ * Validate a webhook message by verifying the signature and the delivery timestamp
76
+ *
77
+ * @param {string|Object} body - The request body of the webhook message
78
+ * @param {Object} headers - The request headers of the webhook message
79
+ * @param {string} [primaryKey] - The primary signature to verify the message with. If it is sent as a parameter,
80
+ it overrides the static variable primarySignatureKey
81
+ * @param {string} [secondaryKey] - The secondary signature to verify the message with. If it is sent as a parameter,
82
+ it overrides the static variable primarySignatureKey
83
+ * @param {int} [maxMessageAge] - The maximum message age (in seconds). Defaults to 10 minutes
84
+ * @returns {boolean} - True or false
85
+ */
86
+ static validateMessage(body: string | object, headers: Record<string, string>, primaryKey?: string, secondaryKey?: string, maxMessageAge?: number): boolean;
87
+ client: BoxClient;
88
+ triggerTypes: Record<'FILE' | 'COMMENT' | 'TASK_ASSIGNMENT' | 'METADATA_INSTANCE' | 'FOLDER' | 'WEBHOOK' | 'COLLABORATION' | 'SHARED_LINK', Record<string, WebhookTriggerType>>;
89
+ validateMessage: typeof Webhooks.validateMessage;
90
+ constructor(client: BoxClient);
91
+ /**
92
+ * Create a new webhook on a given Box object, specified by type and ID.
93
+ *
94
+ * API Endpoint: '/webhooks'
95
+ * Method: POST
96
+ *
97
+ * @param {string} targetID - Box ID of the item to create webhook on
98
+ * @param {ItemType} targetType - Type of item the webhook will be created on
99
+ * @param {string} notificationURL - The URL of your application where Box will notify you of events triggers
100
+ * @param {WebhookTriggerType[]} triggerTypes - Array of event types that trigger notification for the target
101
+ * @param {Function} [callback] - Passed the new webhook information if it was acquired successfully
102
+ * @returns {Promise<Object>} A promise resolving to the new webhook object
103
+ */
104
+ create(targetID: string, targetType: string, notificationURL: string, triggerTypes: WebhookTriggerType[], callback?: Function): any;
105
+ /**
106
+ * Returns a webhook object with the specified Webhook ID
107
+ *
108
+ * API Endpoint: '/webhooks/:webhookID'
109
+ * Method: GET
110
+ *
111
+ * @param {string} webhookID - ID of the webhook to retrieve
112
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
113
+ * @param {Function} [callback] - Passed the webhook information if it was acquired successfully
114
+ * @returns {Promise<Object>} A promise resolving to the webhook object
115
+ */
116
+ get(webhookID: string, options?: Record<string, any>, callback?: Function): any;
117
+ /**
118
+ * Get a list of webhooks that are active for the current application and user.
119
+ *
120
+ * API Endpoint: '/webhooks'
121
+ * Method: GET
122
+ *
123
+ * @param {Object} [options] - Additional options for the request. Can be left null in most cases.
124
+ * @param {int} [options.limit=100] - The number of webhooks to return
125
+ * @param {string} [options.marker] - Pagination marker
126
+ * @param {Function} [callback] - Passed the list of webhooks if successful, error otherwise
127
+ * @returns {Promise<Object>} A promise resolving to the collection of webhooks
128
+ */
129
+ getAll(options?: {
130
+ limit?: number;
131
+ marker?: string;
132
+ }, callback?: Function): any;
133
+ /**
134
+ * Update a webhook
135
+ *
136
+ * API Endpoint: '/webhooks/:webhookID'
137
+ * Method: PUT
138
+ *
139
+ * @param {string} webhookID - The ID of the webhook to be updated
140
+ * @param {Object} updates - Webhook fields to update
141
+ * @param {string} [updates.address] - The new URL used by Box to send a notification when webhook is triggered
142
+ * @param {WebhookTriggerType[]} [updates.triggers] - The new events that triggers a notification
143
+ * @param {Function} [callback] - Passed the updated webhook information if successful, error otherwise
144
+ * @returns {Promise<Object>} A promise resolving to the updated webhook object
145
+ */
146
+ update(webhookID: string, updates?: {
147
+ address?: string;
148
+ triggers?: WebhookTriggerType[];
149
+ }, callback?: Function): any;
150
+ /**
151
+ * Delete a specified webhook by ID
152
+ *
153
+ * API Endpoint: '/webhooks/:webhookID'
154
+ * Method: DELETE
155
+ *
156
+ * @param {string} webhookID - ID of webhook to be deleted
157
+ * @param {Function} [callback] - Empty response body passed if successful.
158
+ * @returns {Promise<void>} A promise resolving to nothing
159
+ */
160
+ delete(webhookID: string, callback?: Function): any;
161
+ }
162
+ /**
163
+ * @module box-node-sdk/lib/managers/webhooks
164
+ * @see {@Link Webhooks}
165
+ */
166
+ export = Webhooks;