Skip to main content

A JavaScript/TypeScript package providing common utilities and logic shared across all Temboplus-Afloat Projects

This package works with Node.js, DenoIt is unknown whether this package works with Cloudflare Workers, Bun, Browsers
It is unknown whether this package works with Cloudflare Workers
This package works with Node.js
This package works with Deno
It is unknown whether this package works with Bun
It is unknown whether this package works with Browsers
JSR Score
70%
Published
3 weeks ago (0.1.29)
class User

Represents a user in Afloat

This class centralizes user-related logic, simplifying interaction with user-related data and ensuring consistent permission checks across the application.

Constructors

new
User(data: { profile: Profile; token: string; access: string[]; resetPassword: boolean; loginCredentials: { name: string; identity: string; }; })

Creates a new instance of the User class.

Properties

Logged-in identity: phone-number or email address

Logged-in user name

The user's Afloat profile, containing personal information such as name, contact details, and account information.

Indicates whether the user is required to change their default password.

Afloat users are initially provided with a default username and password. After the first successful login, resetPassword will be set to true to prompt the user to set a new password.

The user's authentication token. This token must be passed in the request headers for all authenticated API endpoints.

private
permissionsMap: Record<string, boolean>

A map of permission keys to boolean values, indicating whether the user has access to specific actions or features in the system.

Methods

can(permission: string): boolean

Checks if the user has a specific permission.

Serializes the User instance to a JSON string.

Static Methods

fromJSON(jsonString: string): User

Creates a new User instance from a JSON string.

Add Package

deno add jsr:@temboplus/afloat

Import symbol

import { User } from "@temboplus/afloat";

---- OR ----

Import directly with a jsr specifier

import { User } from "jsr:@temboplus/afloat";

Add Package

npx jsr add @temboplus/afloat

Import symbol

import { User } from "@temboplus/afloat";

Add Package

yarn dlx jsr add @temboplus/afloat

Import symbol

import { User } from "@temboplus/afloat";

Add Package

pnpm dlx jsr add @temboplus/afloat

Import symbol

import { User } from "@temboplus/afloat";

Add Package

bunx jsr add @temboplus/afloat

Import symbol

import { User } from "@temboplus/afloat";