> ## Documentation Index
> Fetch the complete documentation index at: https://turnkey-0e7c1f5b-bc-add-sdk-typedoc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# IframeStamper

# Class: IframeStamper

Defined in: [index.ts:129](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L129)

Stamper to use with `@turnkey/http`'s `TurnkeyClient`
Creating a stamper inserts an iframe in the current page.

## Constructors

### Constructor

> **new IframeStamper**(`config`): `IframeStamper`

Defined in: [index.ts:142](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L142)

Creates a new iframe stamper. This function *does not* insert the iframe in the DOM.
Call `.init()` to insert the iframe element in the DOM.

#### Parameters

##### config

[`TIframeStamperConfig`](../TIframeStamperConfig/readme)

#### Returns

`IframeStamper`

## Properties

### container

> **container**: `HTMLElement`

Defined in: [index.ts:130](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L130)

***

### iframe

> **iframe**: `HTMLIFrameElement`

Defined in: [index.ts:131](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L131)

***

### iframeOrigin

> **iframeOrigin**: `string`

Defined in: [index.ts:132](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L132)

***

### iframePublicKey

> **iframePublicKey**: `null` | `string`

Defined in: [index.ts:133](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L133)

***

### messageChannel

> **messageChannel**: `MessageChannel`

Defined in: [index.ts:134](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L134)

## Methods

### applySettings()

> **applySettings**(`settings`): `Promise`\<`boolean`>

Defined in: [index.ts:451](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L451)

Function to apply settings on allowed parameters in the iframe
This is used to style the HTML element used for plaintext in wallet and private key import.

#### Parameters

##### settings

[`TIframeSettings`](../TIframeSettings/readme)

#### Returns

`Promise`\<`boolean`>

***

### clear()

> **clear**(): `void`

Defined in: [index.ts:276](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L276)

Removes the iframe from the DOM

#### Returns

`void`

***

### clearEmbeddedKey()

> **clearEmbeddedKey**(): `Promise`\<`null`>

Defined in: [index.ts:306](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L306)

Clears the embedded key within an iframe.

#### Returns

`Promise`\<`null`>

***

### extractKeyEncryptedBundle()

> **extractKeyEncryptedBundle**(`keyFormat`?): `Promise`\<`string`>

Defined in: [index.ts:440](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L440)

Function to extract an encrypted bundle from the iframe
The bundle should be encrypted to Turnkey's Signer enclave's initial public key
Encryption should be performed with HPKE (RFC 9180).
The key format to encode the private key in before it's encrypted and imported: HEXADECIMAL or SOLANA. Defaults to HEXADECIMAL.
This is used during the private key import flow.

#### Parameters

##### keyFormat?

[`KeyFormat`](../KeyFormat/readme)

#### Returns

`Promise`\<`string`>

***

### extractWalletEncryptedBundle()

> **extractWalletEncryptedBundle**(): `Promise`\<`string`>

Defined in: [index.ts:427](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L427)

Function to extract an encrypted bundle from the iframe
The bundle should be encrypted to Turnkey's Signer enclave's initial public key
Encryption should be performed with HPKE (RFC 9180).
This is used during the wallet import flow.

#### Returns

`Promise`\<`string`>

***

### getEmbeddedPublicKey()

> **getEmbeddedPublicKey**(): `Promise`\<`null` | `string`>

Defined in: [index.ts:294](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L294)

Returns the public key, or `null` if the underlying iframe isn't properly initialized.
This differs from the above in that it reaches out to the live iframe to see if an embedded key exists.

#### Returns

`Promise`\<`null` | `string`>

***

### init()

> **init**(`dangerouslyOverrideIframeKeyTtl`?): `Promise`\<`string`>

Defined in: [index.ts:234](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L234)

Inserts the iframe on the page and returns a promise resolving to the iframe's public key

#### Parameters

##### dangerouslyOverrideIframeKeyTtl?

`number`

Optional TTL override for the iframe's embedded key (default 48 hours). Only use this if you are intentional about the security implications.

#### Returns

`Promise`\<`string`>

***

### initEmbeddedKey()

> **initEmbeddedKey**(): `Promise`\<`null` | `string`>

Defined in: [index.ts:319](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L319)

Creates a new embedded key within an iframe. If an embedded key already exists, this will return it.
This is primarily to be used in conjunction with `clearEmbeddedKey()`: after an embedded key is cleared,
this can be used to create a new one.

#### Returns

`Promise`\<`null` | `string`>

the newly created embedded public key.

***

### injectCredentialBundle()

> **injectCredentialBundle**(`bundle`): `Promise`\<`boolean`>

Defined in: [index.ts:361](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L361)

Function to inject a new credential into the iframe
The bundle should be encrypted to the iframe's initial public key
Encryption should be performed with HPKE (RFC 9180).
This is used during recovery and auth flows.

#### Parameters

##### bundle

`string`

#### Returns

`Promise`\<`boolean`>

***

### injectImportBundle()

> **injectImportBundle**(`bundle`, `organizationId`, `userId`): `Promise`\<`boolean`>

Defined in: [index.ts:409](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L409)

Function to inject an import bundle into the iframe
This is used to initiate either the wallet import flow or the private key import flow.

#### Parameters

##### bundle

`string`

##### organizationId

`string`

##### userId

`string`

#### Returns

`Promise`\<`boolean`>

***

### injectKeyExportBundle()

> **injectKeyExportBundle**(`bundle`, `organizationId`, `keyFormat`?): `Promise`\<`boolean`>

Defined in: [index.ts:374](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L374)

Function to inject an export bundle into the iframe
The bundle should be encrypted to the iframe's initial public key
Encryption should be performed with HPKE (RFC 9180).
The key format to encode the private key in after it's exported and decrypted: HEXADECIMAL or SOLANA. Defaults to HEXADECIMAL.
This is used during the private key export flow.

#### Parameters

##### bundle

`string`

##### organizationId

`string`

##### keyFormat?

[`KeyFormat`](../KeyFormat/readme)

#### Returns

`Promise`\<`boolean`>

***

### injectWalletExportBundle()

> **injectWalletExportBundle**(`bundle`, `organizationId`): `Promise`\<`boolean`>

Defined in: [index.ts:392](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L392)

Function to inject an export bundle into the iframe
The bundle should be encrypted to the iframe's initial public key
Encryption should be performed with HPKE (RFC 9180).
This is used during the wallet export flow.

#### Parameters

##### bundle

`string`

##### organizationId

`string`

#### Returns

`Promise`\<`boolean`>

***

### onMessageHandler()

> **onMessageHandler**(`event`): `void`

Defined in: [index.ts:191](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L191)

#### Parameters

##### event

`MessageEvent`

#### Returns

`void`

***

### publicKey()

> **publicKey**(): `null` | `string`

Defined in: [index.ts:286](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L286)

Returns the public key, or `null` if the underlying iframe isn't properly initialized.

#### Returns

`null` | `string`

***

### stamp()

> **stamp**(`payload`): `Promise`\<`TStamp`>

Defined in: [index.ts:460](https://github.com/tkhq/sdk/blob/ee72856c3f450731d7501ab05001215768b71500/packages/iframe-stamper/src/index.ts#L460)

Function to sign a payload with the underlying iframe

#### Parameters

##### payload

`string`

#### Returns

`Promise`\<`TStamp`>
