@turnkey/iframe-stamper
package, while sharing a similar purpose with the @turnkey/api-key-stamper
, caters specifically to the unique context of iframes. This package is designed for stamping requests within an iframe, using credentials for Turnkey’s API, but operates distinctly from the API key stamper. Unlike the API key stamper, which has direct access to the API private key to compute signatures or stamps directly, the iframe stamper interacts with credentials in a more indirect manner.
It leverages the postMessage
communication mechanism to send and receive messages within the iframe, ensuring the credential does not leave its secure environment. This approach is particularly crucial in sensitive flows such as Email Auth, and Key or Wallet Export, where heightened security is required. The @turnkey/iframe-stamper
works in tandem with @turnkey/http
, facilitating secure and efficient communication in these specific use cases.
By bridging the gap between the iframe’s isolated environment and Turnkey’s API, the iframe stamper plays a pivotal role in maintaining the integrity and security of the credential while ensuring seamless operation within the iframe context.
@turnkey/iframe-stamper
client, install it as follows:
constructor(config: TIframeStamperConfig): IframeStamper
TIframeStamperConfig
init: () => Promise<string>
injectCredentialBundle: (bundle: string) => Promise<boolean>
Promise<boolean>
that resolves to true
if the bundle was successfully injected into the iframe, or false
otherwise.
injectKeyExportBundle: (bundle: string) => Promise<boolean>
Promise<boolean>
which resolves to true
if the bundle was successfully injected into the iframe, or false
otherwise.
injectWalletExportBundle: (bundle: string) => Promise<boolean>
Promise<boolean>
which resolves to true
if the bundle is successfully injected into the iframe, or false
otherwise.
publicKey: () => string | null
null
if the underlying iframe isn’t properly initialized. This method is useful for retrieving the public key which is necessary for various operations like credential injection or request stamping.
clear: () => void