@datalayer/core
Version:
[](https://datalayer.io)
57 lines (56 loc) • 1.88 kB
JavaScript
/*
* Copyright (c) 2023-2025 Datalayer, Inc.
* Distributed under the terms of the Modified BSD License.
*/
/**
* User profile management API functions for the Datalayer platform.
*
* Provides functions for retrieving and managing user profile information.
*
* @module api/iam/profile
*/
import { requestDatalayerAPI } from '../DatalayerApi';
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants';
import { validateToken } from '../utils/validation';
/**
* Get current authenticated user profile
* @param token - Authentication token (required)
* @param baseUrl - Base URL for the API (defaults to production IAM URL)
* @returns Current user profile information
*/
export const me = async (token, baseUrl = DEFAULT_SERVICE_URLS.IAM) => {
validateToken(token);
return requestDatalayerAPI({
url: `${baseUrl}${API_BASE_PATHS.IAM}/me`,
method: 'GET',
token,
});
};
/**
* Get current user identity information
* @param token - Authentication token (required)
* @param baseUrl - Base URL for the API (defaults to production IAM URL)
* @returns Current user identity and profile information
*/
export const whoami = async (token, baseUrl = DEFAULT_SERVICE_URLS.IAM) => {
validateToken(token);
return requestDatalayerAPI({
url: `${baseUrl}${API_BASE_PATHS.IAM}/whoami`,
method: 'GET',
token,
});
};
/**
* Get current user identity information
* @param token - Authentication token (required)
* @param baseUrl - Base URL for the API (defaults to production IAM URL)
* @returns Current user identity and profile information
*/
export const memberships = async (token, baseUrl = DEFAULT_SERVICE_URLS.IAM) => {
validateToken(token);
return requestDatalayerAPI({
url: `${baseUrl}${API_BASE_PATHS.IAM}/memberships`,
method: 'GET',
token,
});
};