Skip to content

Commit bfeee48

Browse files
authored
fix: more careful checks for EIP-1193 provider (#290)
1 parent 4c3170a commit bfeee48

File tree

1 file changed

+6
-8
lines changed
  • packages/synapse-sdk/src/pdp

1 file changed

+6
-8
lines changed

packages/synapse-sdk/src/pdp/auth.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,14 @@ export class PDPAuthHelper {
9595
return true
9696
}
9797

98-
// Check for window.ethereum (browser environment)
99-
if (typeof globalThis !== 'undefined' && 'window' in globalThis) {
100-
const win = globalThis as any
101-
if (win.window?.ethereum != null) {
102-
return true
103-
}
98+
// If it's a JsonRpcProvider or WebSocketProvider, it's not a browser provider
99+
// These can sign locally with a wallet
100+
if (provider instanceof ethers.JsonRpcProvider || provider instanceof ethers.WebSocketProvider) {
101+
return false
104102
}
105103

106-
// Check for provider with send method
107-
if ('send' in provider || 'request' in provider) {
104+
// For any other provider with request method (potential EIP-1193 provider)
105+
if ('request' in provider && typeof (provider as any).request === 'function') {
108106
return true
109107
}
110108
} catch {

0 commit comments

Comments
 (0)