{"version":3,"file":"MeApi.cjs","names":[],"sources":["../../../src/apis/me/MeApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport type { Account } from '../accounts/types'\nimport type { User } from '../users/types'\nimport type {\n  RegisterTokenPayload,\n  SetOtpSecretKeyPayload,\n  TakeoverPayload,\n  UpdateMeAccountPayload,\n  UpdateMePayload,\n  UpdateMeStatusPayload,\n} from './types'\n\nexport class MeApi {\n  protected readonly client: ApiClient\n\n  constructor(client: ApiClient) {\n    this.client = client\n  }\n\n  /**\n   * Returns the currently authenticated user, including their roles, departments, and timetable.\n   * @permissions users.view\n   */\n  getMe(headers?: Record<string, string>): Promise<User> {\n    return this.client.get<User>('/me', headers)\n  }\n\n  /** Returns the account associated with the currently authenticated user. */\n  getAccount(headers?: Record<string, string>): Promise<Account> {\n    return this.client.get<Account>('/me/account', headers)\n  }\n\n  /**\n   * Returns credit and usage amounts for the current account.\n   * Excludes Digisac's own internal credit amounts.\n   */\n  getAccountAmounts(headers?: Record<string, string>): Promise<Record<string, unknown>> {\n    return this.client.get<Record<string, unknown>>('/me/get-account-amounts', headers)\n  }\n\n  /**\n   * Returns a URL to the Agnus billing/plan management page for the current account.\n   * @permissions myAccount.myPlan\n   */\n  getAgnusMyPlanUrl(headers?: Record<string, string>): Promise<{ url: string }> {\n    return this.client.get<{ url: string }>('/me/account/agnus-my-plan-url', headers)\n  }\n\n  /**\n   * Updates the current user's profile fields such as name, language, and preferences.\n   * If a new password is provided, it is validated against the last 6 password history entries\n   * and all existing access tokens for the user are revoked.\n   */\n  updateMe(body: UpdateMePayload, headers?: Record<string, string>): Promise<User> {\n    return this.client.put<User, UpdateMePayload>('/me', body, headers)\n  }\n\n  /** Updates account-level settings such as name, settings object, wizard progress, and default department. */\n  updateAccount(body: UpdateMeAccountPayload, headers?: Record<string, string>): Promise<Account> {\n    return this.client.put<Account, UpdateMeAccountPayload>('/me/account', body, headers)\n  }\n\n  /**\n   * Updates the presence status of the current user (`online`, `offline`, or `away`).\n   * If setting to `online`, validates the user's timetable first — if outside working hours,\n   * the status is set to `offline` instead.\n   */\n  updateStatus(body: UpdateMeStatusPayload, headers?: Record<string, string>): Promise<User> {\n    return this.client.put<User, UpdateMeStatusPayload>('/me/status', body, headers)\n  }\n\n  /**\n   * Extends the grace period for the current account when it has expired or is about to expire.\n   * Returns the updated account.\n   */\n  extendAccountGracePeriod(headers?: Record<string, string>): Promise<Account> {\n    return this.client.post<Account>('/me/account/extend-grace-period', undefined, headers)\n  }\n\n  /**\n   * Registers a OneSignal push notification token for the current user.\n   * Used to enable push notifications on mobile/web clients.\n   */\n  registerToken(body: RegisterTokenPayload, headers?: Record<string, string>): Promise<void> {\n    return this.client.post<void, RegisterTokenPayload>(\n      '/me/one-signal/register-token',\n      body,\n      headers,\n    )\n  }\n\n  /** Marks the current user's first login as complete by setting `isFirstLogin` to `false`. */\n  reportFirstLogin(headers?: Record<string, string>): Promise<User> {\n    return this.client.post<User>('/me/report-login', undefined, headers)\n  }\n\n  /**\n   * Sets the current user's status to `online` for the given client and emits a takeover event,\n   * which signals other connected sessions to yield control to this one.\n   */\n  takeover(body?: TakeoverPayload, headers?: Record<string, string>): Promise<void> {\n    return this.client.post<void, TakeoverPayload>('/me/takeover', body, headers)\n  }\n\n  /**\n   * Stores a 16-character OTP secret key on the current user.\n   * This must be called before activating OTP authentication via `activateOtpAuth`.\n   */\n  setOtpSecretKey(body: SetOtpSecretKeyPayload, headers?: Record<string, string>): Promise<void> {\n    return this.client.patch<void, SetOtpSecretKeyPayload>('/me/set-otp-secret-key', body, headers)\n  }\n\n  /**\n   * Activates OTP (two-factor) authentication for the current user.\n   * Requires the `x-digisac-otp` header with a valid TOTP token generated from the secret key\n   * previously set via `setOtpSecretKey`.\n   */\n  activateOtpAuth(headers?: Record<string, string>): Promise<boolean> {\n    return this.client.post<boolean>('/me/activate-otp-auth', undefined, headers)\n  }\n}\n"],"mappings":";;;AAYA,IAAa,QAAb,MAAmB;CACjB,AAAmB;CAEnB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