# Interface: MincaAuth

Defined in: [packages/core/src/session/auth.ts:403](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L403)

## Properties

| Property | Modifier | Type | Description | Defined in |
| ------ | ------ | ------ | ------ | ------ |
| <a id="property-staysignedin"></a> `staySignedIn` | `readonly` | `object` | - | [packages/core/src/session/auth.ts:551](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L551) |
| `staySignedIn.choice` | `public` | () => [`StaySignedIn`](https://minca.dev/api/session/type-aliases/StaySignedIn.md) | - | [packages/core/src/session/auth.ts:552](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L552) |
| `staySignedIn.setChoice` | `public` | (`choice`) => `Promise`\<`void`\> | - | [packages/core/src/session/auth.ts:553](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L553) |
| `staySignedIn.until` | `public` | () => `Date` \| `null` | - | [packages/core/src/session/auth.ts:554](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L554) |
| <a id="property-usernames"></a> `usernames` | `readonly` | `string` \| `null` | Where new accounts take usernames (`usernames` in the config); null when none are offered | [packages/core/src/session/auth.ts:434](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L434) |

## Methods

### acceptPairing()

```ts
acceptPairing(): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:452](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L452)

Meets the computer the pairing link names. Signed in to another account,
it stops once the account arrives and sets `pairingArrival`: answer with
`answerPairing`.

#### Returns

`Promise`\<`void`\>

***

### addPasskey()

```ts
addPasskey(): Promise<boolean>;
```

Defined in: [packages/core/src/session/auth.ts:461](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L461)

Adds a passkey for this site. During setup, moves the flow on; otherwise needs `confirm` first.

#### Returns

`Promise`\<`boolean`\>

***

### answerPairing()

```ts
answerPairing(take): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:454](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L454)

Takes the account a pairing brought (added, or switched to if already here), or lets it go

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `take` | `boolean` |

#### Returns

`Promise`\<`void`\>

***

### cancelPod()

```ts
cancelPod(): void;
```

Defined in: [packages/core/src/session/auth.ts:466](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L466)

#### Returns

`void`

***

### choosePod()

```ts
choosePod(): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:414](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L414)

Opens a pod. Needs a click. Signed in, it asks what should happen to the data first (`podChoice`).

#### Returns

`Promise`\<`void`\>

***

### clearError()

```ts
clearError(): void;
```

Defined in: [packages/core/src/session/auth.ts:456](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L456)

#### Returns

`void`

***

### codeSaved()

```ts
codeSaved(): void;
```

Defined in: [packages/core/src/session/auth.ts:442](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L442)

The recovery code has been kept somewhere safe; on to choosing a way in

#### Returns

`void`

***

### confirm()

```ts
confirm(proof): Promise<boolean>;
```

Defined in: [packages/core/src/session/auth.ts:485](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L485)

Asks the person to prove it is them, with the account's password, a
passkey on this device or the recovery code, even though they are signed
in: a page left open, or a sign-in kept for days, is no proof anyone is
there. For a few minutes after, the recovery code can be read and the
account offered to a phone. A wrong answer sets `error`.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `proof` | \| \{ `password`: `string`; \} \| \{ `passkey`: `true`; \} \| \{ `code`: `string`; \} |

#### Returns

`Promise`\<`boolean`\>

***

### confirmPod()

```ts
confirmPod(how): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:465](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L465)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `how` | `"combine"` \| `"switch"` |

#### Returns

`Promise`\<`void`\>

***

### connectedElsewhere()

```ts
connectedElsewhere(origin): readonly object[];
```

Defined in: [packages/core/src/session/auth.ts:528](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L528)

Other accounts in this place that a carrier at `origin` is connected to from this home.
One browser extension carries one account, so connecting it here moves it
off theirs — worth saying before it happens.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `origin` | `string` |

#### Returns

readonly `object`[]

***

### connections()

```ts
connections(): readonly Connection[];
```

Defined in: [packages/core/src/session/auth.ts:522](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L522)

Apps this account is connected to from this home, newest first

#### Returns

readonly [`Connection`](https://minca.dev/api/session/interfaces/Connection.md)[]

***

### createAccount()

```ts
createAccount(name, options?): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:440](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L440)

Makes an account. With `username`, it is claimed for the account in the
background while the rest of setup goes on, and `username` in the state
says how that went.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `name` | `string` |
| `options?` | \{ `username?`: `string`; \} |
| `options.username?` | `string` |

#### Returns

`Promise`\<`void`\>

***

### disconnect()

```ts
disconnect(origin, options?): Promise<boolean>;
```

Defined in: [packages/core/src/session/auth.ts:547](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L547)

Disconnects an app: revokes its note in every space it could write in —
and, for a whole-account app, in the account registry — so nothing it
writes from now on counts, and forgets it. What this home had
seen it write stays. What it could already read, it keeps — reading is
holding a space's key, and that is not taken back.

Disconnecting by origin disconnects every connection made from it but a
carrier, which goes only by `{ audience }`, its own key. Programs
connected by code are at the home's own origin; `{ audience }`
disconnects one.

The app hears of it when the revokes reach it: from this node, or a
device that has them. `{ waitMs }` waits up to that long for a peer to
take them in, and the answer says whether one did. False means they are
still only here: the app keeps working until this home is next online
with another of the account's devices or apps.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `origin` | `string` |
| `options?` | \{ `audience?`: `string`; `waitMs?`: `number`; \} |
| `options.audience?` | `string` |
| `options.waitMs?` | `number` |

#### Returns

`Promise`\<`boolean`\>

***

### dismissMoved()

```ts
dismissMoved(): void;
```

Defined in: [packages/core/src/session/auth.ts:477](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L477)

#### Returns

`void`

***

### dismissPairing()

```ts
dismissPairing(): void;
```

Defined in: [packages/core/src/session/auth.ts:455](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L455)

#### Returns

`void`

***

### finishSetup()

```ts
finishSetup(): void;
```

Defined in: [packages/core/src/session/auth.ts:444](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L444)

Leaves the optional `pod` step with the data in this browser

#### Returns

`void`

***

### forgetBrowserCopy()

```ts
forgetBrowserCopy(): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:468](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L468)

Removes the copy this browser kept after a move into a pod

#### Returns

`Promise`\<`void`\>

***

### getState()

```ts
getState(): AuthState;
```

Defined in: [packages/core/src/session/auth.ts:404](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L404)

#### Returns

[`AuthState`](https://minca.dev/api/session/interfaces/AuthState.md)

***

### grant()

```ts
grant(choice): Promise<Omit<Grant, "home">>;
```

Defined in: [packages/core/src/session/auth.ts:504](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L504)

Gives an app access, as the account home: makes any spaces it asked for,
signs a note from the account to the app's key for these spaces, and
remembers the app as connected. The seed signs here and goes nowhere.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `choice` | [`GrantChoice`](https://minca.dev/api/session/interfaces/GrantChoice.md) |

#### Returns

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

***

### grantCarry()

```ts
grantCarry(choice): Promise<Omit<CarryGrant, "home">>;
```

Defined in: [packages/core/src/session/auth.ts:510](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L510)

Starts using a carrier, as the account home: makes its carry space, fills
it with a pass for every space, and remembers it as connected. The
carrier gets no key that reads or writes a space.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `choice` | \{ `origin`: `string`; `request`: [`ConnectRequest`](https://minca.dev/api/session/interfaces/ConnectRequest.md); \} |
| `choice.origin` | `string` |
| `choice.request` | [`ConnectRequest`](https://minca.dev/api/session/interfaces/ConnectRequest.md) |

#### Returns

`Promise`\<`Omit`\<[`CarryGrant`](https://minca.dev/api/session/interfaces/CarryGrant.md), `"home"`\>\>

***

### isConfirmed()

```ts
isConfirmed(): boolean;
```

Defined in: [packages/core/src/session/auth.ts:489](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L489)

Whether `confirm` succeeded in the last few minutes

#### Returns

`boolean`

***

### mayGrant()

```ts
mayGrant(): boolean;
```

Defined in: [packages/core/src/session/auth.ts:494](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L494)

Whether `grant` and `grantCarry` may run now: `isConfirmed`, or a sign-in
with a password, passkey or the recovery code in the last few minutes.

#### Returns

`boolean`

***

### offerToPhone()

```ts
offerToPhone(onStage): Promise<PairingOffer>;
```

Defined in: [packages/core/src/session/auth.ts:498](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L498)

Starts offering this account to a phone

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `onStage` | (`stage`) => `void` |

#### Returns

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

***

### propose()

```ts
propose(choice): Promise<Proposed>;
```

Defined in: [packages/core/src/session/auth.ts:520](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L520)

Adds the subscriptions an app connected from this home proposed, as the
account home — the ones the person kept, naming it, looking only at
spaces it may reach.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `choice` | [`ProposeChoice`](https://minca.dev/api/session/interfaces/ProposeChoice.md) |

#### Returns

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

#### Throws

When no app from `origin` is connected here (a carrier or a program connected by code doesn't count), or a proposal names a space it wasn't given

***

### recoveryCode()

```ts
recoveryCode(): string | null;
```

Defined in: [packages/core/src/session/auth.ts:496](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L496)

The recovery code of the open account, for a few minutes after `confirm`. Null otherwise.

#### Returns

`string` \| `null`

***

### removeAccount()

```ts
removeAccount(): Promise<boolean>;
```

Defined in: [packages/core/src/session/auth.ts:476](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L476)

Removes the open account from this browser, after `confirm` and once no
app is connected from here: signs out, then deletes the account and its
spaces' data from this browser, as clearing its site data would. Copies elsewhere, on
other devices, carriers or hosts, stay; without one, its private spaces
are gone. Not for an account kept in a folder: that folder is its copy.

#### Returns

`Promise`\<`boolean`\>

***

### removeShortcut()

```ts
removeShortcut(kind): Promise<boolean>;
```

Defined in: [packages/core/src/session/auth.ts:464](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L464)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `kind` | `"passphrase"` \| `"passkey"` |

#### Returns

`Promise`\<`boolean`\>

***

### rename()

```ts
rename(name): Promise<boolean>;
```

Defined in: [packages/core/src/session/auth.ts:459](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L459)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `name` | `string` |

#### Returns

`Promise`\<`boolean`\>

***

### reopenPod()

```ts
reopenPod(): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:412](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L412)

Opens again the pod named in `podToReopen`, signed in if it was kept so. Needs a click.

#### Returns

`Promise`\<`void`\>

***

### select()

```ts
select(accountId): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:419](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L419)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `accountId` | `string` |

#### Returns

`Promise`\<`void`\>

***

### setPassword()

```ts
setPassword(password): Promise<boolean>;
```

Defined in: [packages/core/src/session/auth.ts:463](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L463)

Sets or replaces the account's password. During setup, moves the flow on; otherwise needs `confirm` first.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `password` | `string` |

#### Returns

`Promise`\<`boolean`\>

***

### settled()

```ts
settled(): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:446](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L446)

Resolves once the work setup began in the background is done: the username's claim, the host's handover

#### Returns

`Promise`\<`void`\>

***

### showExisting()

```ts
showExisting(): void;
```

Defined in: [packages/core/src/session/auth.ts:430](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L430)

"I already have an account": the ways to reach one from here

#### Returns

`void`

***

### showRestore()

```ts
showRestore(): void;
```

Defined in: [packages/core/src/session/auth.ts:432](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L432)

The recovery code form, for the selected account if there is one

#### Returns

`void`

***

### showSignIn()

```ts
showSignIn(): void;
```

Defined in: [packages/core/src/session/auth.ts:426](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L426)

#### Returns

`void`

***

### showWelcome()

```ts
showWelcome(): void;
```

Defined in: [packages/core/src/session/auth.ts:428](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L428)

Back to "new here, or not?"

#### Returns

`void`

***

### signInWithCode()

```ts
signInWithCode(code): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:421](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L421)

Opens an account with its recovery code. Where it has no passkey or password yet, sets one up next.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `code` | `string` |

#### Returns

`Promise`\<`void`\>

***

### signInWithPasskey()

```ts
signInWithPasskey(): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:424](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L424)

#### Returns

`Promise`\<`void`\>

***

### signInWithPassword()

```ts
signInWithPassword(password): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:423](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L423)

Opens the selected account with its password. A recovery code typed or filled here works too.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `password` | `string` |

#### Returns

`Promise`\<`void`\>

***

### signOut()

```ts
signOut(options?): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:565](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L565)

Signs this home out on this device: it forgets the unlocked account, lets
apps whose time has passed go, and revokes its own session key. The apps
connected from here keep their notes until they run out, as apps stay
signed in when you sign out of where you signed in to them.
`{ disconnect: true }` disconnects them first, and the programs connected
through them: their keys are revoked, and each sees it and asks to connect
again. Carriers stay: they hold nothing that writes.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `options?` | \{ `disconnect?`: `boolean`; \} |
| `options.disconnect?` | `boolean` |

#### Returns

`Promise`\<`void`\>

***

### start()

```ts
start(): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:408](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L408)

Looks for accounts and resumes a kept sign-in. Safe to call more than once.

#### Returns

`Promise`\<`void`\>

***

### startCreating()

```ts
startCreating(): void;
```

Defined in: [packages/core/src/session/auth.ts:425](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L425)

#### Returns

`void`

***

### subscribe()

```ts
subscribe(listener): () => void;
```

Defined in: [packages/core/src/session/auth.ts:406](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L406)

Called after every change. Returns a function that stops it.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `listener` | (`state`) => `void` |

#### Returns

() => `void`

***

### useBrowser()

```ts
useBrowser(): Promise<void>;
```

Defined in: [packages/core/src/session/auth.ts:416](https://github.com/leifriksheim/minca/blob/main/core/src/session/auth.ts#L416)

Keeps accounts in this browser, and stops using a pod if one was open

#### Returns

`Promise`\<`void`\>
