fix(worker-auth): unify token checks and bind job environment
This commit is contained in:
1 parent
feb3723753
commit
020ffbfb23
6 files changed
+138
-37
No files matched your search
@@ -0,0 +1,11 @@
|
||||
import { ConvexError } from 'convex/values';
|
||||
|
||||
export const assertWorkerToken = (provided: string): void => {
|
||||
const expected = process.env.SPOON_WORKER_TOKEN?.trim();
|
||||
if (!expected) {
|
||||
throw new ConvexError('SPOON_WORKER_TOKEN is not configured.');
|
||||
}
|
||||
if (provided.trim() !== expected) {
|
||||
throw new ConvexError('Invalid worker token.');
|
||||
}
|
||||
};
|
||||
Reference in new issue
Block a user