Skip to content

Commit 221ca24

Browse files
committed
feat: add iframe protection feature flag
1 parent 8256e26 commit 221ca24

File tree

5 files changed

+18
-8
lines changed

5 files changed

+18
-8
lines changed

src/connectors/webwallet/helpers/openWebwallet.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ export const openWebwallet = async (
6363
const modalId = "argent-webwallet-modal"
6464
const iframeId = "argent-webwallet-iframe"
6565

66-
const existingIframe = document.getElementById(modalId)
67-
const existingModal = document.getElementById(iframeId)
66+
const existingModal = document.getElementById(modalId)
67+
const existingIframe = document.getElementById(iframeId)
6868

6969
// avoid duplicate iframes
7070
if (existingIframe && existingIframe && existingModal) {

src/connectors/webwallet/helpers/trpc.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const appRouter = t.router({
6464
.input(
6565
z.object({
6666
theme: z.enum(["light", "dark", "auto"]).optional(),
67+
featureFlagIframeProtection: z.boolean().optional(),
6768
}),
6869
)
6970
.output(

src/connectors/webwallet/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import {
88
} from "@starknet-io/types-js"
99
import {
1010
Account,
11-
AccountInterface,
12-
ProviderInterface,
11+
type AccountInterface,
12+
type ProviderInterface,
1313
type ProviderOptions,
1414
} from "starknet"
1515
import {
@@ -41,6 +41,7 @@ interface WebWalletConnectorOptions {
4141
theme?: Theme
4242
ssoToken?: string
4343
authorizedPartyId?: string
44+
featureFlagIframeProtection?: boolean
4445
}
4546

4647
export class WebWalletConnector extends Connector {
@@ -129,7 +130,11 @@ export class WebWalletConnector extends Connector {
129130
} else {
130131
const connectResponse = await (
131132
this._wallet as WebWalletStarknetWindowObject
132-
).connectWebwallet({ theme: this._options.theme })
133+
).connectWebwallet({
134+
theme: this._options.theme,
135+
featureFlagIframeProtection:
136+
this._options.featureFlagIframeProtection,
137+
})
133138
account = connectResponse.account
134139
chainId = connectResponse.chainId
135140
}

src/connectors/webwallet/starknetWindowObject/argentStarknetWindowObject.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export type Theme = "light" | "dark"
3737

3838
type ConnectWebwalletProps = {
3939
theme?: Theme
40+
featureFlagIframeProtection?: boolean
4041
}
4142

4243
export type WebWalletStarknetWindowObject = StarknetWindowObject & {
@@ -64,8 +65,11 @@ export const getArgentStarknetWindowObject = (
6465
return proxyLink.getLoginStatus.mutate()
6566
},
6667
connectWebwallet: (props = {}) => {
67-
const { theme } = props
68-
return proxyLink.connectWebwallet.mutate({ theme })
68+
const { theme, featureFlagIframeProtection } = props
69+
return proxyLink.connectWebwallet.mutate({
70+
theme,
71+
featureFlagIframeProtection,
72+
})
6973
},
7074
connectWebwalletSSO: (token, authorizedPartyId) => {
7175
return proxyLink.connectWebwalletSSO.mutate({ token, authorizedPartyId })

src/connectors/webwallet/starknetWindowObject/wormhole.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export const createModal = async (targetUrl: string, shouldShow: boolean) => {
3939
iframe.setAttribute("allowtransparency", "true")
4040
iframe.setAttribute("transparent", "true")
4141

42-
applyModalStyle(/* modal, */ iframe)
42+
applyModalStyle(iframe)
4343
iframe.style.display = shouldShow ? "block" : "none"
4444

4545
const existingElement = document.getElementById(iframeId)

0 commit comments

Comments
 (0)