File tree Expand file tree Collapse file tree 7 files changed +31
-0
lines changed Expand file tree Collapse file tree 7 files changed +31
-0
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @turnkey/react-wallet-kit " : patch
3+ ---
4+
5+ Added optional ` clearClipboardOnPaste ` to ` handleImportWallet ` and ` handleImportPrivateKey ` . Defaulting to true, this will create the import iframe with ` clipboard-write ` permissions. Allows clipboard to be cleared after pasting in secrets to import.
Original file line number Diff line number Diff line change 1+ ---
2+ " @turnkey/iframe-stamper " : patch
3+ ---
4+
5+ Updated ` TIframeStamperConfig ` to include ` clearClipboardOnPaste ` . Defaulting to true, this will grant the iframe ` clipboard-write ` permissions. Allows clipboard to be cleared after pasting in secrets to import.
Original file line number Diff line number Diff line change @@ -100,6 +100,8 @@ export type TIframeStamperConfig = {
100100 iframeUrl : string ;
101101 iframeElementId : string ;
102102 iframeContainer : HTMLElement | null | undefined ;
103+ // If true, the iframe will clear the clipboard when pasting into it. Defaults to true.
104+ clearClipboardOnPaste ?: boolean | undefined ;
103105} ;
104106
105107export type TIframeStyles = {
@@ -208,6 +210,10 @@ export class IframeStamper {
208210 iframe . id = config . iframeElementId ;
209211 iframe . src = config . iframeUrl ;
210212
213+ if ( config . clearClipboardOnPaste ?? true ) {
214+ iframe . allow = "clipboard-write" ; // Clipboard will clear when pasting in the iframe
215+ }
216+
211217 this . iframe = iframe ;
212218 const iframeUrl = new URL ( config . iframeUrl ) ;
213219 this . iframeOrigin = iframeUrl . origin ;
Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ export function ImportComponent(props: {
3939 onError : ( error : TurnkeyError ) => void ;
4040 successPageDuration ?: number | undefined ; // Duration in milliseconds for the success page to show. If 0, it will not show the success page.
4141 stampWith ?: StamperType | undefined ;
42+ clearClipboardOnPaste ?: boolean | undefined ;
4243 name ?: string ;
4344 organizationId ?: string ;
4445 userId ?: string ;
@@ -51,6 +52,7 @@ export function ImportComponent(props: {
5152 onError,
5253 defaultWalletAccounts,
5354 successPageDuration,
55+ clearClipboardOnPaste,
5456 stampWith,
5557 name,
5658 } = props ;
@@ -121,6 +123,7 @@ export function ImportComponent(props: {
121123 iframeContainer : document . getElementById (
122124 TurnkeyImportIframeContainerId ,
123125 ) ,
126+ clearClipboardOnPaste,
124127 } ) ;
125128 await newImportIframeClient . init ( ) ;
126129 await newImportIframeClient . applySettings ( {
Original file line number Diff line number Diff line change @@ -3996,6 +3996,7 @@ export const ClientProvider: React.FC<ClientProviderProps> = ({
39963996 successPageDuration = 2000 ,
39973997 stampWith,
39983998 walletName,
3999+ clearClipboardOnPaste,
39994000 organizationId,
40004001 userId,
40014002 } = params || { } ;
@@ -4018,6 +4019,9 @@ export const ClientProvider: React.FC<ClientProviderProps> = ({
40184019 { ...( successPageDuration !== undefined && {
40194020 successPageDuration,
40204021 } ) }
4022+ { ...( clearClipboardOnPaste !== undefined && {
4023+ clearClipboardOnPaste, // Note: This is defaulted to true in the IframeStamper
4024+ } ) }
40214025 { ...( stampWith !== undefined && { stampWith } ) }
40224026 { ...( walletName !== undefined && { name : walletName } ) }
40234027 { ...( organizationId !== undefined && { organizationId } ) }
@@ -4050,6 +4054,7 @@ export const ClientProvider: React.FC<ClientProviderProps> = ({
40504054 successPageDuration = 2000 ,
40514055 stampWith,
40524056 keyName,
4057+ clearClipboardOnPaste,
40534058 organizationId,
40544059 } = params || { } ;
40554060 try {
@@ -4070,6 +4075,9 @@ export const ClientProvider: React.FC<ClientProviderProps> = ({
40704075 { ...( successPageDuration !== undefined && {
40714076 successPageDuration,
40724077 } ) }
4078+ { ...( clearClipboardOnPaste !== undefined && {
4079+ clearClipboardOnPaste, // Note: This is defaulted to true in the IframeStamper
4080+ } ) }
40734081 { ...( stampWith !== undefined && { stampWith } ) }
40744082 { ...( keyName !== undefined && { name : keyName } ) }
40754083 { ...( organizationId !== undefined && { organizationId } ) }
Original file line number Diff line number Diff line change @@ -380,6 +380,7 @@ export type ClientContextType = Override<
380380 * @param params.successPageDuration - duration (in ms) for the success page after import (default: 0, no success page).
381381 * @param params.stampWith - parameter to specify the stamper to use for the import (Passkey, ApiKey, or Wallet).
382382 * @param params.walletName - name for the imported wallet, if not provided, an input box will be shown for the name.
383+ * @param params.clearClipboardOnPaste - whether to clear the clipboard after pasting the import bundle (default: true).
383384 * @param params.organizationId - The organization ID to target (defaults to the session's organization ID or the parent organization ID).
384385 * @param params.userId - The user ID to target (defaults to the session's user ID).
385386 *
@@ -402,6 +403,7 @@ export type ClientContextType = Override<
402403 * @param params.successPageDuration - duration (in ms) for the success page after import (default: 0, no success page).
403404 * @param params.stampWith - parameter to specify the stamper to use for the import (Passkey, ApiKey, or Wallet).
404405 * @param params.keyName - name for the imported private key, if not provided, an input box will be shown for the name.
406+ * @param params.clearClipboardOnPaste - whether to clear the clipboard after pasting the import bundle (default: true).
405407 * @param params.organizationId - The organization ID to target (defaults to the session's organization ID or the parent organization ID).
406408 * @param params.userId - The user ID to target (defaults to the session's user ID).
407409 *
Original file line number Diff line number Diff line change @@ -122,6 +122,7 @@ export type HandleImportWalletParams = {
122122 successPageDuration ?: number | undefined ; // Duration in milliseconds for the success page to show. If 0, it will not show the success page.
123123 stampWith ?: StamperType | undefined ;
124124 walletName ?: string ;
125+ clearClipboardOnPaste ?: boolean | undefined ; // If true, the clipboard will be cleared when pasting into the import iframe. Defaults to true.
125126 organizationId ?: string ;
126127 userId ?: string ;
127128} ;
@@ -132,6 +133,7 @@ export type HandleImportPrivateKeyParams = {
132133 successPageDuration ?: number | undefined ; // Duration in milliseconds for the success page to show. If 0, it will not show the success page.
133134 stampWith ?: StamperType | undefined ;
134135 keyName ?: string ;
136+ clearClipboardOnPaste ?: boolean | undefined ; // If true, the clipboard will be cleared when pasting into the import iframe. Defaults to true.
135137 organizationId ?: string ;
136138 userId ?: string ;
137139} ;
You can’t perform that action at this time.
0 commit comments