Skip to content
2 changes: 2 additions & 0 deletions .changeset/test-snapi-detection-do-not-merge.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
1 change: 0 additions & 1 deletion packages/backend/src/__tests__/exports.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe('subpath /jwt exports', () => {
expect(Object.keys(jwtExports).sort()).toMatchInlineSnapshot(`
[
"decodeJwt",
"hasValidSignature",
"signJwt",
"verifyJwt",
]
Expand Down
5 changes: 3 additions & 2 deletions packages/backend/src/jwt/index.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import { withLegacyReturn, withLegacySyncReturn } from './legacyReturn';
import { signJwt as _signJwt } from './signJwt';
import { decodeJwt as _decodeJwt, hasValidSignature as _hasValidSignature, verifyJwt as _verifyJwt } from './verifyJwt';
import { decodeJwt as _decodeJwt, verifyJwt as _verifyJwt } from './verifyJwt';

export type { VerifyJwtOptions } from './verifyJwt';
export type { SignJwtOptions } from './signJwt';

export type JwtAlgorithm = 'HS256' | 'HS384' | 'HS512' | 'RS256' | 'RS384' | 'RS512' | 'ES256' | 'ES384' | 'ES512';

// Introduce compatibility layer to avoid more breaking changes
// TODO(dimkl): This (probably be drop in the next major version)

export const verifyJwt = withLegacyReturn(_verifyJwt);
export const decodeJwt = withLegacySyncReturn(_decodeJwt);

export const signJwt = withLegacyReturn(_signJwt);
export const hasValidSignature = withLegacyReturn(_hasValidSignature);
4 changes: 4 additions & 0 deletions packages/backend/src/webhooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export type VerifyWebhookOptions = {
* The signing secret for the webhook. It's recommended to use the [`CLERK_WEBHOOK_SIGNING_SECRET` environment variable](https://clerk.com/docs/guides/development/clerk-environment-variables#webhooks) instead.
*/
signingSecret?: string;
/**
* Optional tolerance, in seconds, for accepting webhooks whose timestamp falls outside the default replay window.
*/
timestampToleranceSeconds?: number;
Comment thread
jacekradko marked this conversation as resolved.
};

// Standard Webhooks header names
Expand Down
10 changes: 7 additions & 3 deletions packages/shared/src/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
*
* Probably paired with:
* <input type='file' accept='application/JSON' ... />
*
* Renamed from `readJSONFile` to align naming with the rest of the parse-* helpers.
*/
export function readJSONFile(file: File): Promise<unknown> {
export function parseJSONFile(file: File): Promise<unknown> {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.addEventListener('load', function () {
Expand All @@ -28,6 +30,8 @@ const MimeTypeToExtensionMap = Object.freeze({

export type SupportedMimeType = keyof typeof MimeTypeToExtensionMap;

export const extension = (mimeType: SupportedMimeType): string => {
return MimeTypeToExtensionMap[mimeType];
export type MimeTypeExtension = (typeof MimeTypeToExtensionMap)[SupportedMimeType];

export const extension = (mimeType: SupportedMimeType, fallback?: string): string => {
return MimeTypeToExtensionMap[mimeType] ?? fallback ?? '';
};
Loading