Mooncore.Util.Deflist
(mooncore v0.2.4)
Copy Markdown
Converts between role lists and bitmask integers. Used for compact JWT role encoding.
How it works
Given an ordered role list ["admin", "manager", "user"]:
["user"]→ binary"100"→ integer4["admin", "user"]→ binary"101"→ integer5["admin", "manager", "user"]→ binary"111"→ integer7
The integer is then Base58-encoded for the JWT token.
Summary
Functions
Decode an integer bitmask back into a list of role strings.
Encode a list of role strings into an integer bitmask.
Functions
Decode an integer bitmask back into a list of role strings.
number is the bitmask integer.
list is the full ordered list of possible roles.
Encode a list of role strings into an integer bitmask.
roles is the full ordered list of possible roles.
list is the user's active roles.