Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion packages/javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"dist",
"README.md",
"LICENSE",
"SECURITY.md"
"SECURITY.md",
"socket.json"
],
"scripts": {
"clean": "rimraf dist",
Expand Down
6 changes: 6 additions & 0 deletions packages/javascript/socket.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"$schema": "https://cdn.jsdelivr.net/npm/@socketsecurity/config@2/schema.json",
"issueRules": {
"networkAccess": "ignore"
}
}
9 changes: 5 additions & 4 deletions packages/javascript/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,12 @@ export class SupaClient<TFeatures extends FeaturesWithFallbacks> {
}
let response: Response
try {
// Prefer an injected fetchFn (e.g. node-fetch for Node < 18), then
// fall back to the global fetch available in browsers and Node ≥ 18.
// Using `typeof fetch` avoids a globalThis bracket-access pattern
// that static-analysis tools (e.g. socket.dev) flag as suspicious.
const fetchImpl =
this.fetchFn ??
(typeof globalThis !== 'undefined'
? (globalThis as unknown as { fetch?: typeof fetch }).fetch?.bind(globalThis)
: undefined)
this.fetchFn ?? (typeof fetch === 'function' ? fetch.bind(globalThis) : undefined)
if (!fetchImpl) {
throw new Error(
'No fetch implementation available. Provide fetchFn in config or use a runtime with global fetch (e.g., Node 18+, browsers).'
Expand Down
Loading