Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor Buffer usage #965

Merged
merged 2 commits into from Feb 19, 2024
Merged

Refactor Buffer usage #965

merged 2 commits into from Feb 19, 2024

Conversation

benoitgrelard
Copy link
Contributor

@benoitgrelard benoitgrelard commented Feb 19, 2024

Description

Fixes #964

There was a leftover usage of Node's Buffer API.
I have converted it to use the web platform's TextEncoder APIs instead.

I wonder if there's an ESLint plugin that could be used to lint for usages of APIs incompatible with cloudflare workers/edge runtime as it seems easy to let something through without thoroughly testing every single API call. A quick google search didn't bring much up so far.

Documentation

Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.

[ ] Yes

If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.

@benoitgrelard benoitgrelard marked this pull request as ready for review February 19, 2024 09:55
@benoitgrelard benoitgrelard requested a review from a team as a code owner February 19, 2024 09:55
@@ -107,8 +108,9 @@ export class Webhooks {
}

async secureCompare(stringA: string, stringB: string): Promise<boolean> {
const bufferA = Buffer.from(stringA);
const bufferB = Buffer.from(stringB);
const encoder = new TextEncoder();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but maybe this should be a class variable rather than being reinitialised.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, done in b0a8840

@benoitgrelard benoitgrelard merged commit 4d24374 into main Feb 19, 2024
1 check passed
@benoitgrelard benoitgrelard deleted the fix-buffer branch February 19, 2024 11:44
@benoitgrelard benoitgrelard mentioned this pull request Feb 19, 2024
benoitgrelard added a commit that referenced this pull request Feb 19, 2024
## Description

This will include #965 and #966 

## Documentation

Does this require changes to the WorkOS Docs? E.g. the [API
Reference](https://workos.com/docs/reference) or code snippets need
updates.

```
[ ] Yes
```

If yes, link a related docs PR and add a docs maintainer as a reviewer.
Their approval is required.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incompatibility with Cloudflare Workers
2 participants