Skip to content

Commit 0d90322

Browse files
committed
Stabilize precommit: validate SDK auth inputs and shim ws in vitest
1 parent f62da2b commit 0d90322

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

packages/sdk/src/auth.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
* @returns {Promise<Object>} { success: boolean, merchant: Object, token: string }
1919
*/
2020
export async function registerMerchant(client, { email, password, name }) {
21+
if (!email) throw new Error('Email is required');
22+
if (!password) throw new Error('Password is required');
23+
2124
return client.requestUnauthenticated('/auth/register', {
2225
method: 'POST',
2326
body: JSON.stringify({
@@ -37,6 +40,9 @@ export async function registerMerchant(client, { email, password, name }) {
3740
* @returns {Promise<Object>} { success: boolean, merchant: Object, token: string }
3841
*/
3942
export async function loginMerchant(client, { email, password }) {
43+
if (!email) throw new Error('Email is required');
44+
if (!password) throw new Error('Password is required');
45+
4046
return client.requestUnauthenticated('/auth/login', {
4147
method: 'POST',
4248
body: JSON.stringify({

src/test/ws-shim.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export class WebSocket {}
2+
export default WebSocket;

vitest.config.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default defineConfig({
2727
// Skip payment service tests that import system-wallet (ethers/ws issue)
2828
'src/lib/payments/service.test.ts',
2929
'src/lib/payments/service.expiration.test.ts',
30-
// Skip API route test that pulls system-wallet through payment flow (same ws issue)
30+
// Skip API route tests that pull system-wallet through payment flow (same ws issue)
3131
'src/app/api/payments/route.test.ts',
3232
'src/app/api/cron/monitor-payments/route.test.ts',
3333
],
@@ -43,6 +43,8 @@ export default defineConfig({
4343
resolve: {
4444
alias: {
4545
'@': path.resolve(__dirname, './src'),
46+
// Force ws to ESM-compatible shim during tests (ethers transitively imports ws)
47+
'ws': path.resolve(__dirname, './src/test/ws-shim.ts'),
4648
'@noble/curves/secp256k1': path.resolve(__dirname, './node_modules/@noble/curves/secp256k1.js'),
4749
'@noble/curves/ed25519': path.resolve(__dirname, './node_modules/@noble/curves/ed25519.js'),
4850
},

0 commit comments

Comments
 (0)