UNPKG

@esri/arcgis-rest-portal

Version:

ArcGIS Online and Enterprise content and user helpers for @esri/arcgis-rest-request

24 lines 1.1 kB
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc. * Apache-2.0 */ /** * Used to determine the username to use in a request. Will use the `username` passed in the * `requestOptions` if present, otherwise will use the username from the `authentication` option. * This method is used internally to determine the username to use in a request and is async to * support the case where the username is not immediately available. * * @param requestOptions the requests options * @returns the authentecated users username encoded for use in a URL. */ export async function determineUsername(requestOptions) { var _a; if (requestOptions.username) { return encodeURIComponent(requestOptions.username); } if ((_a = requestOptions.authentication) === null || _a === void 0 ? void 0 : _a.username) { return encodeURIComponent(requestOptions.authentication.username); } if (requestOptions.authentication) { return requestOptions.authentication.getUsername().then(encodeURIComponent); } } //# sourceMappingURL=determine-username.js.map