API reference / @jsprismarine/prismarine / permission/model
permission/model
Interfaces
Group
Defined in: packages/prismarine/src/permission/model.ts:49
A group.
Properties
meta
readonlymeta:Readonly<Record<string,string>>
Defined in: packages/prismarine/src/permission/model.ts:55
prefix, suffix, level or anything else a pack reads.
nodes
readonlynodes: readonlyNode[]
Defined in: packages/prismarine/src/permission/model.ts:53
parents
readonlyparents: readonlystring[]
Defined in: packages/prismarine/src/permission/model.ts:52
weight
readonlyweight:number
Defined in: packages/prismarine/src/permission/model.ts:51
A heavier group decides before a lighter one.
Membership
Defined in: packages/prismarine/src/permission/model.ts:42
A membership of a user in a group.
Properties
expires?
readonlyoptionalexpires?:string
Defined in: packages/prismarine/src/permission/model.ts:45
When the membership ends, as ISO 8601; absent for never.
group
readonlygroup:string
Defined in: packages/prismarine/src/permission/model.ts:43
Node
Defined in: packages/prismarine/src/permission/model.ts:35
One node a group or a user holds. node is scope.name, scope.* for a whole scope or * for everything, and a leading - negates. A bare scope.name also covers scope.name.*, as the checks always have.
Properties
expires?
readonlyoptionalexpires?:string
Defined in: packages/prismarine/src/permission/model.ts:38
When the node stops applying, as ISO 8601; absent for never.
node
readonlynode:string
Defined in: packages/prismarine/src/permission/model.ts:36
User
Defined in: packages/prismarine/src/permission/model.ts:59
A user: one subject's own memberships, nodes and meta.
Properties
groups
readonlygroups: readonlyMembership[]
Defined in: packages/prismarine/src/permission/model.ts:62
meta
readonlymeta:Readonly<Record<string,string>>
Defined in: packages/prismarine/src/permission/model.ts:64
name
readonlyname:string
Defined in: packages/prismarine/src/permission/model.ts:61
The name last seen, for reading the file. The key decides who it is.
nodes
readonlynodes: readonlyNode[]
Defined in: packages/prismarine/src/permission/model.ts:63
Type Aliases
Entry
Entry =
Node|Membership
Defined in: packages/prismarine/src/permission/model.ts:115
A node or a membership: what a user or a group holds, each with a spelling and maybe an expiry.
Variables
BUILT_IN_GROUPS
constBUILT_IN_GROUPS: readonlystring[]
Defined in: packages/prismarine/src/permission/model.ts:22
The groups the file always has, which cannot be deleted.
DEFAULT_GROUP
constDEFAULT_GROUP:"default"='default'
Defined in: packages/prismarine/src/permission/model.ts:18
The group every subject holds.
EMPTY_GROUP
constEMPTY_GROUP:Group
Defined in: packages/prismarine/src/permission/model.ts:68
A group with nothing in it, at weight 0.
EVERY_NODE
constEVERY_NODE:"*"='*'
Defined in: packages/prismarine/src/permission/model.ts:25
The node that grants everything, which the operator group holds.
LEVEL_META
constLEVEL_META:"level"='level'
Defined in: packages/prismarine/src/permission/model.ts:28
The meta key that sets a subject's command level, from 0 to 4.
OPERATOR_GROUP
constOPERATOR_GROUP:"operator"='operator'
Defined in: packages/prismarine/src/permission/model.ts:20
The group every operator holds.
Functions
checkExpiry()
checkExpiry(
expires,now):string
Defined in: packages/prismarine/src/permission/model.ts:200
Checks an expiry: an ISO 8601 instant with a time zone, in the future.
Parameters
expires
string
now
number
Returns
string
Throws
InvalidPermissionExpiry when it is not one or is already past.
checkNode()
checkNode(
node):string
Defined in: packages/prismarine/src/permission/model.ts:184
Checks a node's spelling: non-empty segments separated by dots, * alone or as the last segment, and at most one leading -.
Parameters
node
string
Returns
string
Throws
InvalidPermissionNode when the node is not spelled that way.
emptyUser()
emptyUser(
name):User
Defined in: packages/prismarine/src/permission/model.ts:71
A user of this name with nothing of their own.
Parameters
name
string
Returns
entryKey()
entryKey(
entry):string
Defined in: packages/prismarine/src/permission/model.ts:118
The spelling that makes two entries one: the node, or the group.
Parameters
entry
Returns
string
groupJson()
groupJson(
group,now):PermissionGroupJson
Defined in: packages/prismarine/src/permission/model.ts:264
A group as the file writes it, without expired nodes.
Parameters
group
now
number
Returns
isExpired()
isExpired(
__namedParameters,now):boolean
Defined in: packages/prismarine/src/permission/model.ts:108
Whether something with an expiry has expired at now, in milliseconds since the epoch. An expiry that is not an instant counts as expired, so a damaged entry grants nothing.
Parameters
__namedParameters
expires?
string
now
number
Returns
boolean
longerLived()
longerLived<
T>(first,second):T
Defined in: packages/prismarine/src/permission/model.ts:128
Of two entries of one spelling, the one that applies longer; the first when they are equal.
Type Parameters
T
T extends Entry
Parameters
first
T
second
T
Returns
T
mergeEntries()
mergeEntries<
T>(kept,added,choose):T[]
Defined in: packages/prismarine/src/permission/model.ts:137
added merged into kept, each spelling once and in the order first seen. choose says which of two entries of one spelling stays: the kept one, or the longer lived, as the caller decides. It decides between two copies within kept the same way, so a list that already holds a spelling twice loses the copy the policy would not keep.
Type Parameters
T
T extends Entry
Parameters
kept
readonly T[]
added
readonly T[]
choose
(kept, added) => T
Returns
T[]
nextExpiryOf()
nextExpiryOf(
entries,now):number|undefined
Defined in: packages/prismarine/src/permission/model.ts:169
The first moment after now at which one of these entries expires, or undefined when none will: when a client's command list and abilities next need sending again.
Parameters
entries
Iterable<Entry>
now
number
Returns
number | undefined
parseInstant()
parseInstant(
text):number|undefined
Defined in: packages/prismarine/src/permission/model.ts:83
The milliseconds since the epoch an expiry names, or undefined when it is not an instant with a time zone or names a date the calendar does not have.
Parameters
text
string
Returns
number | undefined
readGroup()
readGroup(
value):Group
Defined in: packages/prismarine/src/permission/model.ts:242
The group a value of the file holds. A field that is missing or malformed reads as empty, so one bad line does not refuse the file.
Parameters
value
unknown
Returns
readUser()
readUser(
value):User|undefined
Defined in: packages/prismarine/src/permission/model.ts:253
The user a value of the file holds, or undefined for a value without a name.
Parameters
value
unknown
Returns
User | undefined
userJson()
userJson(
user,now):PermissionUserJson
Defined in: packages/prismarine/src/permission/model.ts:272
A user as the file writes it, without expired nodes and memberships.
Parameters
user
now
number
Returns
withMeta()
withMeta(
meta,key,value):Record<string,string>
Defined in: packages/prismarine/src/permission/model.ts:155
A meta map with key set to value, or without key when value is undefined. Built from entries, so a key such as __proto__ is an own property like any other, as the file reads it.
Parameters
meta
Readonly<Record<string, string>>
key
string
value
string | undefined
Returns
Record<string, string>