minca
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

ParameterTypeDescription
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.codestring-
params.decideTimeoutMs?numberHow long the person has to decide once it has. Default 30 minutes.
params.findTimeoutMs?numberHow long to wait for the home to open at all. Default 10 minutes: the person may make an account first.
params.homestringThe account home it opened: only a peer saying it is that home is asked, and the grant keeps it
params.keyAppKeyThis program's key — the note will be made out to it, and it signs the proof for the home's origin
params.namestringWhat the person sees, e.g. "Agent on leifs-macbook"
params.networkCodeNetwork-
params.onWaiting?(home) => voidTold 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

On this page