ApiSessionFunctions
Function: connectWithCode()
function connectWithCode(params): Promise<Grant>;Defined in: packages/core/src/session/connect-code.ts:351
Connects this program with a code it made (newConnectCode): open connectCodeUrl 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; 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 | 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>
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