UNPKG

@asgardeo/javascript

Version:
48 lines (47 loc) 1.86 kB
/** * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). * * WSO2 LLC. licenses this file to you under the Apache License, * Version 2.0 (the "License"); you may not use this file except * in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ /** * Extracts the organization handle from an Asgardeo base URL. * * This function parses Asgardeo URLs with the standard pattern: * - https://dev.asgardeo.io/t/{orgHandle} * - https://stage.asgardeo.io/t/{orgHandle} * - https://prod.asgardeo.io/t/{orgHandle} * - https://{subdomain}.asgardeo.io/t/{orgHandle} * * @param baseUrl - The base URL of the Asgardeo identity server * @returns The extracted organization handle * @throws {AsgardeoRuntimeError} When the URL doesn't match the expected Asgardeo pattern, * indicating a custom domain is configured and organizationHandle must be provided explicitly * * @example * ```typescript * // Standard Asgardeo URLs * const handle1 = deriveOrganizationHandleFromBaseUrl('https://dev.asgardeo.io/t/dxlab'); * // Returns: 'dxlab' * * const handle2 = deriveOrganizationHandleFromBaseUrl('https://stage.asgardeo.io/t/myorg'); * // Returns: 'myorg' * * // Custom domain - throws error * deriveOrganizationHandleFromBaseUrl('https://custom.example.com/auth'); * // Throws: AsgardeoRuntimeError * ``` */ declare const deriveOrganizationHandleFromBaseUrl: (baseUrl?: string) => string; export default deriveOrganizationHandleFromBaseUrl;