This version (v0.7) has not been published to npm yet.
Skip to content

Profile and sessions ​

The profile namespace reads and updates the logged-in player's data and lists the devices with an open session. All methods require login: without a session (or if it cannot be refreshed), they reject with UNAUTHENTICATED before any call. In tests, the createMockFetch from @getenginex/sdk/testing already answers /me and /me/sessions with realistic data.

Read the profile ​

ts
const me = await enginex.profile.get()
me.displayName // 'Ana Souza'
me.emailVerified // true
me.cpf // '***.456.789-**'

The CPF always comes masked from the gateway; the SDK has no way to return it in full. Fields with no value (avatarUrl, phone...) arrive as empty text, and createdAt is an ISO 8601 date in UTC.

Update the profile ​

Only username and displayName can be updated. Provide at least one (the type does not compile with an empty object); empty text is rejected by the gateway with INVALID_ARGUMENT (400). The response is the full, already updated profile:

ts
try {
  const me = await enginex.profile.update({ displayName: 'Ana S.' })
} catch (e) {
  if (isEnginexError(e, 'INVALID_ARGUMENT')) showError(e.message)
  else throw e
}

Email, phone and password have their own flows in Sign-up and Password.

Login sessions ​

ts
const sessions = await enginex.profile.listSessions()
const others = sessions.filter((s) => !s.current)

await enginex.profile.revokeSession({ sessionId: others[0].id }) // encerra o outro dispositivo

Each session has id, ip, device (user agent), lastActive and current (the session that made the request).

Current state of the gateway

Today the gateway returns only the current session (id: 'current'), with lastActive as free text ('now'), and DELETE /me/sessions/{id} responds with success without actually revoking anything (session management has not been wired to the authentication service yet). The SDK already exposes the final contract; do not treat lastActive as a date and do not rely on revokeSession for security until the gateway implements it.