# Function: connectWithCode()

```ts
function connectWithCode(params): Promise<Grant>;
```

Defined in: [packages/core/src/session/connect-code.ts:351](https://github.com/leifriksheim/minca/blob/main/core/src/session/connect-code.ts#L351)

Connects this program with a code it made ([newConnectCode](https://minca.dev/api/session/functions/newConnectCode.md)): open
[connectCodeUrl](https://minca.dev/api/session/functions/connectCodeUrl.md) for the person, then wait here for their home.

## Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `params` | \{ `check`: (`matches`) => `Promise`\<`void`\>; `code`: `string`; `decideTimeoutMs?`: `number`; `findTimeoutMs?`: `number`; `home`: `string`; `key`: [`AppKey`](https://minca.dev/api/session/interfaces/AppKey.md); `name`: `string`; `network`: `CodeNetwork`; `onWaiting?`: (`home`) => `void`; \} | - |
| `params.check` | (`matches`) => `Promise`\<`void`\> | Asks the person for the check code the home shows, until `matches` says it does; rejecting gives up. The note is kept only once it matches: so a home the person never saw can't connect it. |
| `params.code` | `string` | - |
| `params.decideTimeoutMs?` | `number` | How long the person has to decide once it has. Default 30 minutes. |
| `params.findTimeoutMs?` | `number` | How long to wait for the home to open at all. Default 10 minutes: the person may make an account first. |
| `params.home` | `string` | The account home it opened: only a peer saying it is that home is asked, and the grant keeps it |
| `params.key` | [`AppKey`](https://minca.dev/api/session/interfaces/AppKey.md) | This program's key — the note will be made out to it, and it signs the proof for the home's origin |
| `params.name` | `string` | What the person sees, e.g. "Agent on leifs-macbook" |
| `params.network` | `CodeNetwork` | - |
| `params.onWaiting?` | (`home`) => `void` | Told once the home has heard, and the person is deciding, with where the home lives |

## Returns

`Promise`\<[`Grant`](https://minca.dev/api/session/interfaces/Grant.md)\>

The grant, checked: a records-only note for this key, with `home` the one it opened

## Throws

When the person says no, or nothing answers in time
