Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
4 changes: 2 additions & 2 deletions examples/next-rwa/src/app/idp-management/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import { SsoProviderTable, type IdentityProvider } from '@auth0/universal-components-react';
import { SsoProviderTable, type IdpKnownResponse } from '@auth0/universal-components-react';
import { useRouter } from 'next/navigation';
import { useCallback, useMemo } from 'react';

Expand All @@ -11,7 +11,7 @@ export default function IdpManagementPage() {
}, [router]);

const handleEdit = useCallback(
(provider: IdentityProvider): void => {
(provider: IdpKnownResponse): void => {
router.push(`/idp-management/edit/${provider.id}`);
},
[router],
Expand Down
4 changes: 2 additions & 2 deletions examples/react-spa-npm/src/views/sso-provider-page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { SsoProviderTable, type IdentityProvider } from '@auth0/universal-components-react';
import { SsoProviderTable, type IdpKnownResponse } from '@auth0/universal-components-react';
import { useCallback, useMemo } from 'react';
import { useNavigate } from 'react-router-dom';

Expand All @@ -10,7 +10,7 @@ const SsoProviderPage = () => {
}, [navigate]);

const handleEdit = useCallback(
(provider: IdentityProvider) => {
(provider: IdpKnownResponse) => {
navigate(`/sso-provider/edit/${provider.id}`);
},
[navigate],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ import type { MyOrganization } from '@auth0/myorganization-js';

export type GetConfigurationResponseContent = MyOrganization.GetConfigurationResponseContent;

export type IdpConfig = MyOrganization.GetIdpConfigurationResponseContent;
export type IdpConfigStrategyBase = MyOrganization.IdentityProvidersConfigStrategyBase;
export type GetIdpConfigurationResponseContent = MyOrganization.GetIdpConfigurationResponseContent;
export type IdentityProvidersConfigStrategyBase =
MyOrganization.IdentityProvidersConfigStrategyBase;
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import type {

export type ListIdentityProvidersResponseContent =
MyOrganization.ListIdentityProvidersResponseContent;
export type IdentityProvider = MyOrganization.IdpKnownResponse;
export type IdpKnownResponse = MyOrganization.IdpKnownResponse;
export type CreateIdentityProviderRequestContent =
MyOrganization.CreateIdentityProviderRequestContent;
export type CreateIdentityProviderResponseContent =
Expand All @@ -39,9 +39,9 @@ export type CreateIdpDomainResponseContent = MyOrganization.CreateIdpDomainRespo

export type IdpStrategy = MyOrganization.IdpStrategyEnum;

export type IdentityProviderCreate = Omit<IdentityProvider, 'id'>;
export type IdentityProviderCreate = Omit<IdpKnownResponse, 'id'>;

export type IdentityProviderAssociatedWithDomain = IdentityProvider & {
export type IdentityProviderAssociatedWithDomain = IdpKnownResponse & {
is_associated: boolean;
};

Expand All @@ -56,5 +56,5 @@ export type SCIMTokenCreate = MyOrganization.CreateIdpProvisioningScimTokenReque

export type SCIMToken = MyOrganization.IdpScimTokenCreate;

export type IdpUserAttributeMap = MyOrganization.IdpUserAttributeMapItem[];
export type IdpBaseUserAttributeItem = MyOrganization.BaseUserAttributeMapItem;
export type IdpUserAttributeMapItem = MyOrganization.IdpUserAttributeMapItem;
export type BaseUserAttributeMapItem = MyOrganization.BaseUserAttributeMapItem;
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export type CreateIdpProvisioningScimTokenRequestContent =
MyOrganization.CreateIdpProvisioningScimTokenRequestContent;
export type IdpProvisioningConfig = MyOrganization.IdpProvisioningConfig;
export type IdpScimTokenBase = MyOrganization.IdpScimTokenBase;
export type IdpProvisioningUserAttributeMap = MyOrganization.IdpProvisioningUserAttributeMapItem[];
export type IdpProvisioningUserAttributeMapItem =
MyOrganization.IdpProvisioningUserAttributeMapItem;
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {
AVAILABLE_STRATEGY_LIST,
type ComponentAction,
type IdentityProvider,
type IdpKnownResponse,
type CreateIdentityProviderRequestContentPrivate,
} from '@auth0/universal-components-core';
import type { QueryClient } from '@tanstack/react-query';
Expand Down Expand Up @@ -55,7 +55,7 @@ const createMockSsoProviderCreateProps = (

const createMockCreateAction = (): ComponentAction<
CreateIdentityProviderRequestContentPrivate,
IdentityProvider
IdpKnownResponse
> => ({
disabled: false,
onBefore: vi.fn(() => true),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ComponentAction, IdentityProvider } from '@auth0/universal-components-core';
import type { ComponentAction, IdpKnownResponse } from '@auth0/universal-components-core';
import type { QueryClient } from '@tanstack/react-query';
import { screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
Expand Down Expand Up @@ -55,19 +55,19 @@ const createMockCreateAction = (): ComponentAction<void> => ({
onAfter: vi.fn(),
});

const createMockEditAction = (): ComponentAction<IdentityProvider> => ({
const createMockEditAction = (): ComponentAction<IdpKnownResponse> => ({
disabled: false,
onBefore: vi.fn(() => true),
onAfter: vi.fn(),
});

const createMockDeleteAction = (): ComponentAction<IdentityProvider> => ({
const createMockDeleteAction = (): ComponentAction<IdpKnownResponse> => ({
disabled: false,
onBefore: vi.fn(() => true),
onAfter: vi.fn(),
});

const createMockDeleteFromOrganizationAction = (): ComponentAction<IdentityProvider> => ({
const createMockDeleteFromOrganizationAction = (): ComponentAction<IdpKnownResponse> => ({
disabled: false,
onBefore: vi.fn(() => true),
onAfter: vi.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
* @internal
*/

import type { IdpConfig } from '@auth0/universal-components-core';
import type { GetIdpConfigurationResponseContent } from '@auth0/universal-components-core';
import { useFormContext } from 'react-hook-form';

import { Checkbox } from '@/components/ui/checkbox';
import { FormField, FormItem, FormLabel, FormControl, FormDescription } from '@/components/ui/form';
import { useTranslator } from '@/hooks/shared/use-translator';

interface CommonConfigureFieldsProps {
idpConfig: IdpConfig | null;
idpConfig: GetIdpConfigurationResponseContent | null;
readOnly?: boolean;
customMessages?: Partial<Record<string, unknown>>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import {
STRATEGY_DISPLAY_NAMES,
type IdpBaseUserAttributeItem,
type BaseUserAttributeMapItem,
} from '@auth0/universal-components-core';
import { Info } from 'lucide-react';
import * as React from 'react';
Expand All @@ -20,7 +20,7 @@ import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip
import { useTranslator } from '@/hooks/shared/use-translator';
import type { SsoProviderAttributeMappingsProps } from '@/types/my-organization/idp-management/sso-provider/sso-provider-edit-types';

type AttributeItem = IdpBaseUserAttributeItem & { provisioning_field?: string };
type AttributeItem = BaseUserAttributeMapItem & { provisioning_field?: string };

const SCIM_NAMESPACE = 'urn:ietf:params:scim:schemas:core:2.0:User';

Expand All @@ -38,7 +38,7 @@ const STATUS_VARIANTS: Record<ChangeStatus, 'info' | 'warning' | 'default'> = {
[CHANGE_STATUS.NEW]: 'default',
};

const getChangeStatus = (item: IdpBaseUserAttributeItem): ChangeStatus | null => {
const getChangeStatus = (item: BaseUserAttributeMapItem): ChangeStatus | null => {
const { is_extra: isRemoved, is_missing: isNew } = item;

if (isRemoved && isNew) return CHANGE_STATUS.UPDATED;
Expand All @@ -53,7 +53,7 @@ const AttributeNameCell = ({
section,
t,
}: {
item: IdpBaseUserAttributeItem;
item: BaseUserAttributeMapItem;
section: 'required' | 'optional';
t: (key: string) => string;
}) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import {
getComponentStyles,
type IdentityProvider,
type IdpKnownResponse,
STRATEGY_DISPLAY_NAMES,
} from '@auth0/universal-components-core';
import { Plus } from 'lucide-react';
Expand Down Expand Up @@ -177,7 +177,7 @@ function SsoProviderTableView({ logic, handlers }: SsoProviderTableViewProps) {
[styling, isDarkMode],
);

const columns: Column<IdentityProvider>[] = React.useMemo(
const columns: Column<IdpKnownResponse>[] = React.useMemo(
() => [
{
type: 'text',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type {
CreateIdentityProviderRequestContentPrivate,
IdentityProvider,
IdpKnownResponse,
} from '@auth0/universal-components-core';
import { renderHook, waitFor } from '@testing-library/react';
import { describe, expect, it, vi, beforeEach, type Mock } from 'vitest';
Expand All @@ -21,7 +21,7 @@ describe('useSsoProviderCreate', () => {
const mockCreate = vi.fn();
let mockHandleError: Mock;

const mockIdentityProvider: IdentityProvider = {
const mockIdentityProvider: IdpKnownResponse = {
id: 'idp_123',
name: 'test-provider',
strategy: 'samlp',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {
IdentityProvider,
IdpKnownResponse,
CreateIdpProvisioningScimTokenRequestContent,
OrganizationPrivate,
} from '@auth0/universal-components-core';
Expand Down Expand Up @@ -82,7 +82,7 @@ describe('useSsoProviderEdit', () => {
getMyOrganizationApiClient: () => mockOrgClient,
};

const mockProvider: IdentityProvider = {
const mockProvider: IdpKnownResponse = {
id: mockIdpId,
name: 'test-provider',
strategy: 'samlp',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IdentityProvider, OrganizationPrivate } from '@auth0/universal-components-core';
import type { IdpKnownResponse, OrganizationPrivate } from '@auth0/universal-components-core';
import { renderHook, waitFor } from '@testing-library/react';
import { beforeEach, describe, expect, it, vi } from 'vitest';

Expand All @@ -24,7 +24,7 @@ const { mockedShowToast } = mockToast();

// ===== Mock Data =====

const mockIdentityProviders: IdentityProvider[] = [
const mockIdentityProviders: IdpKnownResponse[] = [
{
id: 'idp-1',
display_name: 'OKTA SSO',
Expand Down Expand Up @@ -357,7 +357,7 @@ describe('useSsoProviderTable', () => {
// Test: Ensures the function safely handles providers without an ID
// Should return false without attempting any API calls
it('should return false if provider has no id', async () => {
const providerWithoutId = { ...mockIdentityProviders[0], id: undefined } as IdentityProvider;
const providerWithoutId = { ...mockIdentityProviders[0], id: undefined } as IdpKnownResponse;

setupMockMyOrgClient({
list: vi.fn().mockResolvedValue({ identity_providers: mockIdentityProviders }),
Expand Down Expand Up @@ -464,7 +464,7 @@ describe('useSsoProviderTable', () => {
// Test: Ensures the function safely handles providers without an ID
// Should not attempt to call the delete API
it('should not delete if provider has no id', async () => {
const providerWithoutId = { ...mockIdentityProviders[0], id: undefined } as IdentityProvider;
const providerWithoutId = { ...mockIdentityProviders[0], id: undefined } as IdpKnownResponse;
const mockDelete = vi.fn();

setupMockMyOrgClient({
Expand Down Expand Up @@ -563,7 +563,7 @@ describe('useSsoProviderTable', () => {
// Test: Ensures the function safely handles providers without an ID
// Should not attempt to call the detach API
it('should not remove if provider has no id', async () => {
const providerWithoutId = { ...mockIdentityProviders[0], id: undefined } as IdentityProvider;
const providerWithoutId = { ...mockIdentityProviders[0], id: undefined } as IdpKnownResponse;
const mockDetach = vi.fn();

setupMockMyOrgClient({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @internal
*/

import { type Domain, type IdentityProvider } from '@auth0/universal-components-core';
import { type Domain, type IdpKnownResponse } from '@auth0/universal-components-core';
import { useCallback, useEffect, useState } from 'react';

import { showToast } from '@/components/auth0/shared/toast';
Expand Down Expand Up @@ -116,7 +116,7 @@ export function useDomainTableLogic({
);

const handleToggleSwitch = useCallback(
async (domain: Domain, provider: IdentityProvider, newCheckedValue: boolean) => {
async (domain: Domain, provider: IdpKnownResponse, newCheckedValue: boolean) => {
if (newCheckedValue) {
try {
await onAssociateToProvider(domain, provider);
Expand Down
6 changes: 3 additions & 3 deletions packages/react/src/hooks/my-organization/use-domain-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import {
type Domain,
type IdentityProvider,
type IdpKnownResponse,
type CreateOrganizationDomainRequestContent,
type IdentityProviderAssociatedWithDomain,
BusinessError,
Expand Down Expand Up @@ -127,7 +127,7 @@ export function useDomainTable({
});

const associateToProviderMutation = useMutation({
mutationFn: async ({ domain, provider }: { domain: Domain; provider: IdentityProvider }) => {
mutationFn: async ({ domain, provider }: { domain: Domain; provider: IdpKnownResponse }) => {
if (
associateToProviderAction?.onBefore &&
!associateToProviderAction.onBefore(domain, provider)
Expand All @@ -145,7 +145,7 @@ export function useDomainTable({
});

const deleteFromProviderMutation = useMutation({
mutationFn: async ({ domain, provider }: { domain: Domain; provider: IdentityProvider }) => {
mutationFn: async ({ domain, provider }: { domain: Domain; provider: IdpKnownResponse }) => {
if (
deleteFromProviderAction?.onBefore &&
!deleteFromProviderAction.onBefore(domain, provider)
Expand Down
15 changes: 10 additions & 5 deletions packages/react/src/hooks/my-organization/use-idp-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

import {
hasApiErrorBody,
type IdpConfig,
type IdpConfigStrategyBase,
type GetIdpConfigurationResponseContent,
type IdentityProvidersConfigStrategyBase,
type IdpStrategy,
} from '@auth0/universal-components-core';
import { useQuery, useQueryClient } from '@tanstack/react-query';
Expand All @@ -22,7 +22,10 @@ export const idpConfigQueryKeys = {
/**
* Mapping from IdpStrategy values to the SDK's strategy config keys.
*/
const STRATEGY_TO_CONFIG_KEY: Record<IdpStrategy, keyof NonNullable<IdpConfig['strategies']>> = {
const STRATEGY_TO_CONFIG_KEY: Record<
IdpStrategy,
keyof NonNullable<GetIdpConfigurationResponseContent['strategies']>
> = {
adfs: 'adfs',
'google-apps': 'googleapps',
oidc: 'oidc',
Expand All @@ -40,7 +43,7 @@ export function useIdpConfig(): UseConfigIdpResult {
const { coreClient } = useCoreClient();
const queryClient = useQueryClient();

const idpConfigQuery = useQuery<IdpConfig | null>({
const idpConfigQuery = useQuery<GetIdpConfigurationResponseContent | null>({
queryKey: idpConfigQueryKeys.config(),
queryFn: async () => {
try {
Expand All @@ -65,7 +68,9 @@ export function useIdpConfig(): UseConfigIdpResult {
const idpConfig = idpConfigQuery.data ?? null;
const strategies = idpConfig?.strategies;

const getStrategyFor = (strategy: IdpStrategy | undefined): IdpConfigStrategyBase | undefined => {
const getStrategyFor = (
strategy: IdpStrategy | undefined,
): IdentityProvidersConfigStrategyBase | undefined => {
if (!strategy || !strategies) return undefined;
const key = STRATEGY_TO_CONFIG_KEY[strategy];
return strategies[key];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
SsoProviderMappers,
type CreateIdentityProviderRequestContent,
type CreateIdentityProviderRequestContentPrivate,
type IdentityProvider,
type IdpKnownResponse,
} from '@auth0/universal-components-core';
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { useCallback } from 'react';
Expand Down Expand Up @@ -55,7 +55,7 @@ export function useSsoProviderCreate({
const createProviderMutation = useMutation({
mutationFn: async (
data: CreateIdentityProviderRequestContentPrivate,
): Promise<IdentityProvider> => {
): Promise<IdpKnownResponse> => {
if (!coreClient) {
throw new Error('Core client not available');
}
Expand All @@ -72,7 +72,7 @@ export function useSsoProviderCreate({
const apiRequestData: CreateIdentityProviderRequestContent =
SsoProviderMappers.createToAPI(formData);

const result: IdentityProvider = await coreClient
const result: IdpKnownResponse = await coreClient
.getMyOrganizationApiClient()
.organization.identityProviders.create(apiRequestData);

Expand Down
Loading
Loading