# Interface: NodeSpaces

Defined in: [packages/core/src/node/types.ts:481](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L481)

## Methods

### access()

```ts
access(spaceId): Promise<SpaceAccess>;
```

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

Roles, members and invites, as the space's access history says now

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |

#### Returns

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

***

### assign()

```ts
assign(
   spaceId, 
   did, 
   role
): Promise<void>;
```

Defined in: [packages/core/src/node/types.ts:507](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L507)

Assigns a role to an account. Needs `/role/assign`

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `did` | `string` |
| `role` | `string` |

#### Returns

`Promise`\<`void`\>

***

### authenticator()

```ts
authenticator(spaceId): Promise<ServerAuth | null>;
```

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

How a node serving this space checks connecting peers and signs its welcome; null for a space it does not hold

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |

#### Returns

`Promise`\<[`ServerAuth`](https://minca.dev/api/core/interfaces/ServerAuth.md) \| `null`\>

***

### carried()

```ts
carried(spaceId, options?): Promise<boolean>;
```

Defined in: [packages/core/src/node/types.ts:535](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L535)

Waits up to `waitMs` (default 3 s) for a connected carrier to hold all this node does of a space

#### Parameters

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

#### Returns

`Promise`\<`boolean`\>

***

### changeKey()

```ts
changeKey(spaceId): Promise<void>;
```

Defined in: [packages/core/src/node/types.ts:519](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L519)

Gives a private space a new key, for a lost device. Needs `/key/change`

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |

#### Returns

`Promise`\<`void`\>

***

### closeInvite()

```ts
closeInvite(spaceId, keyOrLink): Promise<void>;
```

Defined in: [packages/core/src/node/types.ts:517](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L517)

Closes an invite, by link or by its key from `access().invites`. Who joined with it stays.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `keyOrLink` | `string` |

#### Returns

`Promise`\<`void`\>

***

### create()

```ts
create(params): Promise<SpaceSummary>;
```

Defined in: [packages/core/src/node/types.ts:484](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L484)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `params` | [`NewSpace`](https://minca.dev/api/core/interfaces/NewSpace.md) |

#### Returns

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

***

### defineRole()

```ts
defineRole(spaceId, role): Promise<void>;
```

Defined in: [packages/core/src/node/types.ts:505](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L505)

Writes a role's definition, replacing the ones held. Needs `/role/define`

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `role` | [`SpaceRole`](https://minca.dev/api/core/interfaces/SpaceRole.md) |

#### Returns

`Promise`\<`void`\>

***

### get()

```ts
get(spaceId): Promise<SpaceSummary | null>;
```

Defined in: [packages/core/src/node/types.ts:483](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L483)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |

#### Returns

`Promise`\<[`SpaceSummary`](https://minca.dev/api/core/interfaces/SpaceSummary.md) \| `null`\>

***

### hold()

```ts
hold(spaceId): Promise<() => Promise<void>>;
```

Defined in: [packages/core/src/node/types.ts:530](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L530)

Keeps a space syncing until the function it returns is called; it stops once nothing holds it

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |

#### Returns

`Promise`\<() => `Promise`\<`void`\>\>

***

### holdsRole()

```ts
holdsRole(
   spaceId, 
   role, 
   account?
): Promise<boolean>;
```

Defined in: [packages/core/src/node/types.ts:503](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L503)

Whether this account, or `account`, holds every grant of a role at least as wide; may say no wrongly, never yes

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `role` | `string` |
| `account?` | `string` |

#### Returns

`Promise`\<`boolean`\>

***

### invite()

```ts
invite(spaceId, options?): Promise<string>;
```

Defined in: [packages/core/src/node/types.ts:486](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L486)

An invite string. For a private space it carries the key: treat it as a secret

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `options?` | [`InviteOptions`](https://minca.dev/api/core/interfaces/InviteOptions.md) |

#### Returns

`Promise`\<`string`\>

***

### join()

```ts
join(invite, options?): Promise<SpaceSummary>;
```

Defined in: [packages/core/src/node/types.ts:490](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L490)

Joins a space from an invite. `memberKey` lets a node without the account key receive new space keys

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `invite` | `string` |
| `options?` | \{ `memberKey?`: `Uint8Array`\<`ArrayBufferLike`\>; \} |
| `options.memberKey?` | `Uint8Array`\<`ArrayBufferLike`\> |

#### Returns

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

***

### kept()

```ts
kept(
   spaceId, 
   waitMs, 
   since?
): Promise<"keepers" | "peer" | null>;
```

Defined in: [packages/core/src/node/types.ts:545](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L545)

Waits up to `waitMs` (at most a minute) for this node's writes in a space
to be kept elsewhere: by the space's keepers, every write from `since`
(ms) on, all by default (`'keepers'`); or, in a space that names none,
where every member's node is a copy, by a peer connected now that holds
all this node does (`'peer'`). Null when nobody had, in time.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `waitMs` | `number` |
| `since?` | `number` |

#### Returns

`Promise`\<`"keepers"` \| `"peer"` \| `null`\>

***

### leave()

```ts
leave(spaceId): Promise<void>;
```

Defined in: [packages/core/src/node/types.ts:492](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L492)

Gives up the account's place in a space, then forgets it and its key here

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |

#### Returns

`Promise`\<`void`\>

***

### list()

```ts
list(): Promise<readonly SpaceSummary[]>;
```

Defined in: [packages/core/src/node/types.ts:482](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L482)

#### Returns

`Promise`\<readonly [`SpaceSummary`](https://minca.dev/api/core/interfaces/SpaceSummary.md)[]\>

***

### may()

```ts
may(
   spaceId, 
   cmd, 
   args?, 
   account?
): Promise<boolean>;
```

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

Whether this account, or `account`, may invoke a command with these arguments in a space now (spec 03 §2)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `cmd` | `string` |
| `args?` | `Readonly`\<`Record`\<`string`, `unknown`\>\> |
| `account?` | `string` |

#### Returns

`Promise`\<`boolean`\>

***

### preview()

```ts
preview(invite): Promise<InvitePreview>;
```

Defined in: [packages/core/src/node/types.ts:488](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L488)

What an invite or link is for; a short link is fetched from its mailboxes first

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `invite` | `string` |

#### Returns

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

***

### profiles()

```ts
profiles(spaceId): Promise<readonly SpaceProfile[]>;
```

Defined in: [packages/core/src/node/types.ts:549](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L549)

The name each person gave in this space; yours is published from the account's name

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |

#### Returns

`Promise`\<readonly [`SpaceProfile`](https://minca.dev/api/core/interfaces/SpaceProfile.md)[]\>

***

### reached()

```ts
reached(
   spaceId, 
   peer, 
   waitMs
): Promise<boolean>;
```

Defined in: [packages/core/src/node/types.ts:537](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L537)

Waits up to `waitMs` (at most a minute) for one peer, by its key, to hold all this node does of a space; for a node about to close

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `peer` | `string` |
| `waitMs` | `number` |

#### Returns

`Promise`\<`boolean`\>

***

### removeMember()

```ts
removeMember(spaceId, did): Promise<void>;
```

Defined in: [packages/core/src/node/types.ts:511](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L511)

Removes an account and its roles. Needs `/member/remove`, unless it is you

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `did` | `string` |

#### Returns

`Promise`\<`void`\>

***

### revoke()

```ts
revoke(
   spaceId, 
   key, 
   options?
): Promise<boolean>;
```

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

Revokes one of this account's keys, by DID: nothing it writes counts from then on.
With `waitMs`, waits that long for a peer to take it in: true when one did, or with no wait.

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `key` | `string` |
| `options?` | `RevokeOptions` |

#### Returns

`Promise`\<`boolean`\>

***

### send()

```ts
send(
   spaceId, 
   message, 
   to?
): Promise<void>;
```

Defined in: [packages/core/src/node/types.ts:532](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L532)

A live message (at most 64 KB) to peers connected now, `to` an account or a session DID; kept nowhere

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `message` | `unknown` |
| `to?` | `string` |

#### Returns

`Promise`\<`void`\>

***

### setKeepers()

```ts
setKeepers(
   spaceId, 
   keepers, 
   copies?
): Promise<void>;
```

Defined in: [packages/core/src/node/types.ts:523](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L523)

Names the nodes that keep the space whole (at most 16), and how many a write should reach. Needs `/space/keepers`

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `keepers` | readonly [`Keeper`](https://minca.dev/api/core/interfaces/Keeper.md)[] |
| `copies?` | `number` \| `null` |

#### Returns

`Promise`\<`void`\>

***

### setRelays()

```ts
setRelays(spaceId, relays): Promise<void>;
```

Defined in: [packages/core/src/node/types.ts:521](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L521)

Names the relays (wss://, at most 8) the space's members meet on. Needs `/space/relays`

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `relays` | readonly `string`[] |

#### Returns

`Promise`\<`void`\>

***

### status()

```ts
status(spaceId): Promise<SpaceStatus>;
```

Defined in: [packages/core/src/node/types.ts:533](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L533)

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |

#### Returns

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

***

### stepDown()

```ts
stepDown(spaceId, options?): Promise<void>;
```

Defined in: [packages/core/src/node/types.ts:513](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L513)

Stops being a founder but stays, taking role `keep` first when given

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `options?` | \{ `keep?`: `string`; \} |
| `options.keep?` | `string` |

#### Returns

`Promise`\<`void`\>

***

### succeed()

```ts
succeed(spaceId, successor): Promise<void>;
```

Defined in: [packages/core/src/node/types.ts:515](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L515)

Names a space that succeeds this one. Needs `/space/succeed`, or a place here when no one holds it

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `successor` | `string` |

#### Returns

`Promise`\<`void`\>

***

### unassign()

```ts
unassign(
   spaceId, 
   did, 
   role
): Promise<void>;
```

Defined in: [packages/core/src/node/types.ts:509](https://github.com/leifriksheim/minca/blob/main/core/src/node/types.ts#L509)

Takes a role from an account. Needs `/role/unassign`, unless it is your own

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `spaceId` | `string` |
| `did` | `string` |
| `role` | `string` |

#### Returns

`Promise`\<`void`\>
