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
27 changes: 27 additions & 0 deletions .changeset/add-localhost-ip-to-allowlist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
'@reown/appkit-adapter-bitcoin': patch
'@reown/appkit-adapter-ethers': patch
'@reown/appkit-adapter-ethers5': patch
'@reown/appkit-adapter-solana': patch
'@reown/appkit-adapter-wagmi': patch
'@reown/appkit': patch
'@reown/appkit-utils': patch
'@reown/appkit-cdn': patch
'@reown/appkit-cli': patch
'@reown/appkit-codemod': patch
'@reown/appkit-common': patch
'@reown/appkit-controllers': patch
'@reown/appkit-core': patch
'@reown/appkit-experimental': patch
'@reown/appkit-pay': patch
'@reown/appkit-polyfills': patch
'@reown/appkit-scaffold-ui': patch
'@reown/appkit-siwe': patch
'@reown/appkit-siwx': patch
'@reown/appkit-testing': patch
'@reown/appkit-ui': patch
'@reown/appkit-wallet': patch
'@reown/appkit-wallet-button': patch
---

Add 127.0.0.1 to the allowlist for localhost IP address support
3 changes: 3 additions & 0 deletions packages/appkit/src/utils/ConstantsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export const WcConstantsUtil = {
ERROR_INVALID_CHAIN_ID: 32603,
DEFAULT_ALLOWED_ANCESTORS: [
'http://localhost:*',
'https://localhost:*',
'http://127.0.0.1:*',
'https://127.0.0.1:*',
'https://*.pages.dev',
'https://*.vercel.app',
'https://*.ngrok-free.app',
Expand Down
52 changes: 52 additions & 0 deletions packages/appkit/tests/utils/HelpersUtil.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { describe, expect, test } from 'vitest'

import { type CaipNetwork, ConstantsUtil } from '@reown/appkit-common'

import { WcConstantsUtil } from '../../src/utils/ConstantsUtil'
import { WcHelpersUtil } from '../../src/utils/HelpersUtil'

const mockEthereumNetwork = {
Expand Down Expand Up @@ -586,5 +587,56 @@ describe('WcHelpersUtil', () => {
WcHelpersUtil.isOriginAllowed('https://app.SAFE.org', allowedPatterns, defaultOrigins)
).toBe(false)
})

test('should allow 127.0.0.1 IP address with HTTP', () => {
expect(
WcHelpersUtil.isOriginAllowed(
'http://127.0.0.1:3000',
[],
WcConstantsUtil.DEFAULT_ALLOWED_ANCESTORS
)
).toBe(true)
expect(
WcHelpersUtil.isOriginAllowed(
'http://127.0.0.1:8080',
[],
WcConstantsUtil.DEFAULT_ALLOWED_ANCESTORS
)
).toBe(true)
})

test('should allow 127.0.0.1 IP address with HTTPS', () => {
expect(
WcHelpersUtil.isOriginAllowed(
'https://127.0.0.1:3000',
[],
WcConstantsUtil.DEFAULT_ALLOWED_ANCESTORS
)
).toBe(true)
expect(
WcHelpersUtil.isOriginAllowed(
'https://127.0.0.1:8443',
[],
WcConstantsUtil.DEFAULT_ALLOWED_ANCESTORS
)
).toBe(true)
})

test('should allow localhost with HTTPS', () => {
expect(
WcHelpersUtil.isOriginAllowed(
'https://localhost:3000',
[],
WcConstantsUtil.DEFAULT_ALLOWED_ANCESTORS
)
).toBe(true)
expect(
WcHelpersUtil.isOriginAllowed(
'https://localhost:8443',
[],
WcConstantsUtil.DEFAULT_ALLOWED_ANCESTORS
)
).toBe(true)
})
})
})
Loading