Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "a2387ff", "specHash": "4ccce13", "version": "1.10.0" }
{ "engineHash": "d26e99e", "specHash": "4ccce13", "version": "1.10.0" }
33 changes: 33 additions & 0 deletions migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- [Configuration](#configuration)
- [As-User header](#as-user-header)
- [Custom Base URLs](#custom-base-urls)
- [Webhook validation](#webhook-validation)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

Expand Down Expand Up @@ -577,3 +578,35 @@ const newClient = client.withCustomBaseUrls({
oauth2Url: 'https://account.box.com/api/oauth2',
});
```

## Webhook validation

Webhook validation is used to validate a webhook message by verifying the signature and the delivery timestamp.

**Legacy (`Box Node SDK`):**

In the old SDK, you could pass the `body` as either a `JSON` object or a `string`, and it would return a `boolean` value indicating whether the message was valid.

```typescript
let isValid = BoxSDK.validateWebhookMessage(
body,
headers,
primaryKey,
secondaryKey,
);
```

**Modern (`Box TypeScript SDK`):**

In the new SDK, the `WebhooksManager.validateMessage()` method requires the `body` to be of type `string`.
So if the body is in `JSON` type, you must convert it to a `string` using `JSON.stringify(body)` before calling `validateMessage()`.

```typescript
let stringBody = JSON.stringify(body);
let isValid = await WebhooksManager.validateMessage(
stringBody,
headers,
primaryKey,
{ secondaryKey: secondaryKey } satisfies ValidateMessageOptionalsInput,
);
```
Loading