const hasGrant = await Koji.identity.checkGrants(['username', 'push_notifications']);
Manages authentication and authorization on the frontend of your Koji app.
Checks whether the user has granted authorizations to the Koji app. Use this method to determine whether to request authorization for certain capabilities.
grants
- AuthGrantCapability, List of authorization grants to check for the user.
Promise<Boolean>, Indicates whether the user has already granted authorization for the capabilities.
const hasGrant = await Koji.identity.checkGrants(['username', 'push_notifications']);
Source: frontend/identity/index.ts#L88
Gets a token identifying the current user.
Promise<IdentityResult>, Identity information for the current user of the Koji app.
const { token, presumedRole, presumedAttributes } = await Koji.identity.getToken()
Source: frontend/identity/index.ts#L57
Requests the specified authorization grants from the user for the Koji app.
grants
- AuthGrantCapability, List of authorization grants to request from the user.
usageDescription
- String (Optional), Custom message to display when requesting the grant.
Promise<String>, Indicates whether authorization for the capabilities was successfully obtained from the user.
const hasGrant = await Koji.identity.requestGrants(['username', 'push_notifications']);
Source: frontend/identity/index.ts#L112
Identity information for the current user of the Koji app.
presumedAttributes
- PresumedAttributes, Additional user attributes, which are returned if the user has granted username authorization via [[requestGrants]].
presumedRole
- 'admin' | 'user' | 'unknown', Presumed role of the current user as the owner/creator (`admin`), not the owner (`user`), or not logged in (`unknown`).
Admin actions must still be secured on the backend by resolving the user’s role.
token
- String, Short-lived token to identify the user.
User attributes that are determined via a client-side API call.
globalId
- String (Optional), The user's global Koji account ID
profilePicture
- String (Optional), Koji avatar for the user.
username
- String (Optional), Koji username for the user.
User attributes that are determined via a client-side API call.
globalId
- String (Optional), The user's global Koji account ID
profilePicture
- String (Optional), Koji avatar for the user.
username
- String (Optional), Koji username for the user.
Capabilities that a user can grant the current Koji authorization to use.