# new Profile(tokenSource, serviceUrl)
Parameters:
| Name | Type | Description |
|---|---|---|
tokenSource |
string
|
function
|
|
serviceUrl |
string
|
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. |
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.
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 ( |
|
call |
string
|
Path to call relative to |
|
body |
*
|
<optional> |
Request body. Serialised to JSON unless already a string. |
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 |
|
body |
*
|
<optional> |
Request body, serialised to JSON. |
Promise.<ServiceResponse>
# put(call, body) → {Promise.<ServiceResponse>}
Sends an authenticated PUT request.
Parameters:
| Name | Type | Description |
|---|---|---|
call |
string
|
Path relative to |
body |
*
|
Request body, serialised to JSON. |
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.
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. |
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. |
Resolves with { result: 'ok' } on success.
Promise.<ServiceResponse>
Example
await profile.update('Ada Lovelace')