[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / identity/Subject

# identity/Subject

## Type Aliases

### Subject

> **Subject** = \{ `kind`: `"xbox"`; `xuid`: `string`; \} \| \{ `kind`: `"java"`; `uuid`: `string`; \} \| \{ `edition?`: `"java"`; `kind`: `"offline"`; `name`: `string`; \}

Defined in: [packages/prismarine/src/identity/Subject.ts:13](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/identity/Subject.ts#L13)

A player as one platform knows them.

#### Union Members

##### Type Literal

\{ `kind`: `"xbox"`; `xuid`: `string`; \}

An Xbox Live account, by its XUID.

***

##### Type Literal

\{ `kind`: `"java"`; `uuid`: `string`; \}

A Java Edition account, by its Mojang profile UUID. No login produces one yet.

***

##### Type Literal

\{ `edition?`: `"java"`; `kind`: `"offline"`; `name`: `string`; \}

A player on an offline-mode server, by the name the client typed. `edition` marks a Java
Edition login, whose player is not the Bedrock player of the same name: the two keep their
own records and can play at once. Permission files ignore it, so an entry for an offline
name covers both editions.

***

### SubjectKind

> **SubjectKind** = [`Subject`](#subject)\[`"kind"`\]

Defined in: [packages/prismarine/src/identity/Subject.ts:27](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/identity/Subject.ts#L27)

The platforms a subject can come from.

## Variables

### SUBJECT\_KINDS

> `const` **SUBJECT\_KINDS**: readonly \[`"xbox"`, `"java"`, `"offline"`\]

Defined in: [packages/prismarine/src/identity/Subject.ts:30](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/identity/Subject.ts#L30)

Every [SubjectKind](#subjectkind), in the order a file lists its sections.

## Functions

### isSubjectKind()

> **isSubjectKind**(`value`): value is "java" \| "xbox" \| "offline"

Defined in: [packages/prismarine/src/identity/Subject.ts:37](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/identity/Subject.ts#L37)

Whether a string read from a file names a [SubjectKind](#subjectkind).

#### Parameters

##### value

`unknown`

#### Returns

value is "java" \| "xbox" \| "offline"

***

### loginSubject()

> **loginSubject**(`login`): [`Subject`](#subject)

Defined in: [packages/prismarine/src/identity/Subject.ts:97](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/identity/Subject.ts#L97)

The subject of a login. A chain the server verified against Xbox Live gives the account's XUID;
any other login is an offline player known by name, whatever XUID the client claimed.

#### Parameters

##### login

What the login carried and whether it was verified.

###### name

`string`

###### verified

`boolean`

###### xuid

`string`

#### Returns

[`Subject`](#subject)

The subject.

***

### parseSubject()

> **parseSubject**(`kind`, `key`): [`Subject`](#subject) \| `undefined`

Defined in: [packages/prismarine/src/identity/Subject.ts:65](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/identity/Subject.ts#L65)

The subject a file section and key name, the reverse of [subjectKey](#subjectkey).

#### Parameters

##### kind

`"java"` \| `"xbox"` \| `"offline"`

The section's kind.

##### key

`string`

The key under it.

#### Returns

[`Subject`](#subject) \| `undefined`

The subject, or undefined for an empty key.

***

### sameSubject()

> **sameSubject**(`a`, `b`): `boolean`

Defined in: [packages/prismarine/src/identity/Subject.ts:83](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/identity/Subject.ts#L83)

Whether two subjects are the same player on the same platform. An offline `Steve` is never the
Xbox account named `Steve`.

#### Parameters

##### a

[`Subject`](#subject)

##### b

[`Subject`](#subject)

#### Returns

`boolean`

***

### subjectId()

> **subjectId**(`subject`): `string`

Defined in: [packages/prismarine/src/identity/Subject.ts:89](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/identity/Subject.ts#L89)

One string for both the kind and the key, for a `Map` key or a log line. It is not a file
layout and not the `xbox:Steve` form `/perms` accepts; those are spelled where they belong.

#### Parameters

##### subject

[`Subject`](#subject)

#### Returns

`string`

***

### subjectKey()

> **subjectKey**(`subject`): `string`

Defined in: [packages/prismarine/src/identity/Subject.ts:46](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/identity/Subject.ts#L46)

The string a file keys this subject under inside its kind's section: the XUID, the UUID or the
name. No other module spells the layout; [parseSubject](#parsesubject) is the reverse.

#### Parameters

##### subject

[`Subject`](#subject)

The subject.

#### Returns

`string`

The key.
