Class

Profile

Profile(tokenSource, serviceUrl)

User-scoped client for profile operations on the Scenid Auth Service.

Obtained via sdk.asUser(idToken).Profile(). All methods require a valid user token — they cannot be called with an admin (service) token.

Constructor

# new Profile(tokenSource, serviceUrl)

Parameters:
Name Type Description
tokenSource string | function
serviceUrl string

View Source services/Profile.class.js, line 19

Example
const profile = sdk.asUser(idToken).Profile()

const { result } = await profile.get()
console.log(result.displayName, result.emailHint)

Extends

Methods

# delete(password) → {Promise.<ServiceResponse>}

Permanently deletes the current user's account.

The user must confirm their current password. The account is anonymised rather than hard-deleted: the email and display name are replaced with placeholder values and the registration status is set to deactivated.

Parameters:
Name Type Description
password string

The user's current password for confirmation.

Overrides:

View Source services/Profile.class.js, line 95

auth/wrong-password – provided password did not match.

Error

Resolves with { result: 'ok' } on success.

Promise.<ServiceResponse>
Example
await profile.delete(confirmedPassword)

# get() → {Promise.<ServiceResponse>}

Returns the current user's profile.

Response shape: { tenantId, uid, displayName, photoURL, emailHint }. The emailHint field masks the local part of the email address (e.g. *****@example.com) to avoid exposing it to client-side code.

Overrides:

View Source services/Profile.class.js, line 41

Promise.<ServiceResponse>
Example
const { result } = await profile.get()
// { tenantId: 't-1', uid: 'u-1', displayName: 'Ada', emailHint: '*****@example.com', photoURL: null }

# async makeRequest(method, call, bodyopt) → {Promise.<ServiceResponse>}

Makes an authenticated HTTP request to the service and returns the parsed response.

Acquires a token, constructs the full endpoint URL, serialises the body as JSON when provided, and parses the JSON response. Throws a typed error on network failure or non-JSON responses.

Parameters:
Name Type Attributes Description
method string

HTTP method (GET, POST, PUT, or DELETE).

call string

Path to call relative to serviceUrl (leading / optional).

body * <optional>

Request body. Serialised to JSON unless already a string.

Overrides:

View Source services/ScenidCloudService.class.js, line 66

sdk/fetch-failed – network-level failure.

Error

sdk/endpoint-invalid – service returned 404 with non-JSON body.

Error

sdk/non-json-response – response body could not be parsed.

Error
Promise.<ServiceResponse>

# post(call, bodyopt) → {Promise.<ServiceResponse>}

Sends an authenticated POST request.

Parameters:
Name Type Attributes Description
call string

Path relative to serviceUrl.

body * <optional>

Request body, serialised to JSON.

Overrides:

View Source services/ScenidCloudService.class.js, line 142

Promise.<ServiceResponse>

# put(call, body) → {Promise.<ServiceResponse>}

Sends an authenticated PUT request.

Parameters:
Name Type Description
call string

Path relative to serviceUrl.

body *

Request body, serialised to JSON.

Overrides:

View Source services/ScenidCloudService.class.js, line 132

Promise.<ServiceResponse>

# requestPasswordReset() → {Promise.<ServiceResponse>}

Sends a password-reset email to the current user's registered address.

No body is required — the server derives the email from the authenticated token.

View Source services/Profile.class.js, line 78

Resolves with { result: 'ok' } on success.

Promise.<ServiceResponse>
Example
await profile.requestPasswordReset()

# setAvatar(photoURL) → {Promise.<ServiceResponse>}

Updates the current user's avatar photo URL.

Parameters:
Name Type Description
photoURL string

Publicly accessible URL of the new avatar image.

View Source services/Profile.class.js, line 65

Resolves with { result: 'ok' } on success.

Promise.<ServiceResponse>
Example
await profile.setAvatar('https://cdn.example.com/avatars/ada.jpg')

# update(displayName) → {Promise.<ServiceResponse>}

Updates the current user's display name.

Parameters:
Name Type Description
displayName string

New display name.

View Source services/Profile.class.js, line 53

Resolves with { result: 'ok' } on success.

Promise.<ServiceResponse>
Example
await profile.update('Ada Lovelace')