@niledatabase/react 2.5.0-alpha.0 → 3.0.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/GoogleLoginButton/GoogleLoginButton.d.ts +1 -1
- package/dist/GoogleLoginButton/GoogleLoginButton.stories.d.ts +0 -1
- package/dist/SignInForm/SignInForm.d.ts +3 -0
- package/dist/SignInForm/index.d.ts +1 -0
- package/dist/{LoginForm → SignInForm}/types.d.ts +1 -2
- package/dist/SignUpForm/types.d.ts +4 -4
- package/dist/UserTenantList/CreateUser.d.ts +1 -2
- package/dist/UserTenantList/UserList.d.ts +2 -2
- package/dist/UserTenantList/UserModal.d.ts +1 -2
- package/dist/index.d.ts +5 -7
- package/dist/lib/SimpleForm/types.d.ts +1 -0
- package/dist/react.cjs.development.js +46 -345
- package/dist/react.cjs.development.js.map +1 -1
- package/dist/react.cjs.production.min.js +1 -1
- package/dist/react.cjs.production.min.js.map +1 -1
- package/dist/react.esm.d.ts +5 -7
- package/dist/react.esm.js +44 -340
- package/dist/react.esm.js.map +1 -1
- package/package.json +3 -3
- package/dist/LoginForm/LoginForm.d.ts +0 -3
- package/dist/LoginForm/SingleSignOn.d.ts +0 -7
- package/dist/LoginForm/index.d.ts +0 -2
- package/dist/SSO/BaseSSOForm.d.ts +0 -8
- package/dist/SSO/Okta.d.ts +0 -3
- package/dist/SSO/SSO.stories.d.ts +0 -6
- package/dist/SSO/index.d.ts +0 -3
- package/dist/SSO/types.d.ts +0 -8
- /package/dist/{LoginForm → SignInForm}/UserLoginForm.stories.d.ts +0 -0
|
@@ -7,6 +7,5 @@ declare const meta: {
|
|
|
7
7
|
};
|
|
8
8
|
export default meta;
|
|
9
9
|
export declare function Basic(): React.JSX.Element;
|
|
10
|
-
export declare function BasicWithTenantNameProvider(): React.JSX.Element;
|
|
11
10
|
export declare function AlphaVersionWithOutProvider(): React.JSX.Element;
|
|
12
11
|
export declare function AlphaVersionWithProvider(): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './SignInForm';
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { LoginRequest } from '@niledatabase/browser';
|
|
2
1
|
import { Attribute } from '../lib/SimpleForm/types';
|
|
3
2
|
export type AllowedAny = any;
|
|
4
3
|
export type LoginInfo = {
|
|
5
4
|
email: string;
|
|
6
5
|
password: string;
|
|
7
6
|
};
|
|
8
|
-
type LoginSuccess = (response:
|
|
7
|
+
type LoginSuccess = (response: AllowedAny, formValues: LoginInfo, ...args: AllowedAny) => void;
|
|
9
8
|
export interface Props {
|
|
10
9
|
beforeMutate?: (data: AllowedAny) => AllowedAny;
|
|
11
10
|
onSuccess: LoginSuccess;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CreateBasicUserRequest, User } from '@niledatabase/browser';
|
|
2
2
|
import { Attribute } from '../lib/SimpleForm/types';
|
|
3
|
-
export type
|
|
4
|
-
type SignInSuccess = (response: void |
|
|
3
|
+
export type SignUpInfo = CreateBasicUserRequest;
|
|
4
|
+
type SignInSuccess = (response: void | User, formValues: SignUpInfo) => void;
|
|
5
5
|
export type AllowedAny = any;
|
|
6
6
|
export interface Props {
|
|
7
7
|
onSuccess: SignInSuccess;
|
|
8
|
-
onError?: (e: Error, info:
|
|
8
|
+
onError?: (e: Error, info: SignUpInfo) => void;
|
|
9
9
|
beforeMutate?: (data: AllowedAny) => AllowedAny;
|
|
10
10
|
attributes?: Attribute[];
|
|
11
11
|
buttonText?: string;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SignUp201Response } from '@niledatabase/browser';
|
|
3
2
|
type Props = {
|
|
4
3
|
allowCreation: boolean;
|
|
5
4
|
buttonText: string;
|
|
6
|
-
onUserCreateSuccess?: (user:
|
|
5
|
+
onUserCreateSuccess?: (user: any) => void;
|
|
7
6
|
};
|
|
8
7
|
export default function CreateUser(props: Props): React.JSX.Element | null;
|
|
9
8
|
export {};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { SxProps } from '@mui/system/styleFunctionSx/styleFunctionSx';
|
|
3
3
|
import { Theme } from '@mui/system/createTheme';
|
|
4
|
-
import {
|
|
4
|
+
import { User } from '@niledatabase/browser';
|
|
5
5
|
type ColumnNames = string;
|
|
6
6
|
type Props = {
|
|
7
7
|
data: void | User[];
|
|
8
8
|
allowCreation?: boolean;
|
|
9
9
|
buttonText?: string;
|
|
10
|
-
onUserCreateSuccess?: (user:
|
|
10
|
+
onUserCreateSuccess?: (user: any) => void;
|
|
11
11
|
slots?: {
|
|
12
12
|
dataGrid?: SxProps<Theme>;
|
|
13
13
|
};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SignUp201Response } from '@niledatabase/browser';
|
|
3
2
|
export type UserFormProps = {
|
|
4
3
|
open: boolean;
|
|
5
4
|
setOpen: (open: boolean) => void;
|
|
6
|
-
refetch?: (user:
|
|
5
|
+
refetch?: (user: any) => void;
|
|
7
6
|
};
|
|
8
7
|
export default function AddUser(props: UserFormProps): React.JSX.Element;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
export { NileProvider } from './context';
|
|
2
|
-
export { default as
|
|
1
|
+
export { NileProvider, useApi } from './context';
|
|
2
|
+
export { default as Google } from './GoogleLoginButton';
|
|
3
3
|
export * from './GoogleLoginButton';
|
|
4
4
|
export * from './SignUpForm';
|
|
5
|
-
export { default as
|
|
6
|
-
export * from './
|
|
7
|
-
export { default as
|
|
5
|
+
export { default as SignUpForm } from './SignUpForm';
|
|
6
|
+
export * from './SignInForm';
|
|
7
|
+
export { default as SignInForm } from './SignInForm';
|
|
8
8
|
export * from './UserTenantList';
|
|
9
9
|
export { default as UserTenantList } from './UserTenantList';
|
|
10
|
-
export * from './SSO';
|
|
11
|
-
export { default as SSOForm } from './SSO';
|
|
12
10
|
export { Attribute as FormAttribute, AttributeType as FormAttributeType, } from './lib/SimpleForm/types';
|
|
13
11
|
export * from 'next-auth/react';
|
|
@@ -11,6 +11,7 @@ var Box = require('@mui/joy/Box');
|
|
|
11
11
|
var Button = require('@mui/joy/Button');
|
|
12
12
|
var Stack = require('@mui/joy/Stack');
|
|
13
13
|
var Typography = require('@mui/joy/Typography');
|
|
14
|
+
var react = require('next-auth/react');
|
|
14
15
|
var Alert = require('@mui/joy/Alert');
|
|
15
16
|
var reactHookForm = require('react-hook-form');
|
|
16
17
|
var Input = require('@mui/joy/Input');
|
|
@@ -27,9 +28,6 @@ var List = require('@mui/joy/List');
|
|
|
27
28
|
var ListItem = require('@mui/joy/ListItem');
|
|
28
29
|
var xDataGrid = require('@mui/x-data-grid');
|
|
29
30
|
var Add = require('@mui/icons-material/Add');
|
|
30
|
-
var CopyAll = require('@mui/icons-material/CopyAll');
|
|
31
|
-
var CheckCircleOutlined = require('@mui/icons-material/CheckCircleOutlined');
|
|
32
|
-
var react = require('next-auth/react');
|
|
33
31
|
|
|
34
32
|
function _interopNamespaceDefault(e) {
|
|
35
33
|
var n = Object.create(null);
|
|
@@ -64,7 +62,6 @@ function Themer({
|
|
|
64
62
|
}), children);
|
|
65
63
|
}
|
|
66
64
|
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
68
65
|
const queryClient = /*#__PURE__*/new reactQuery.QueryClient();
|
|
69
66
|
const defaultContext = {
|
|
70
67
|
api: /*#__PURE__*/new Browser({
|
|
@@ -102,7 +99,8 @@ const NileProvider = props => {
|
|
|
102
99
|
credentials: 'include'
|
|
103
100
|
}),
|
|
104
101
|
tenantId: String(tenantId),
|
|
105
|
-
apiUrl
|
|
102
|
+
apiUrl,
|
|
103
|
+
appUrl
|
|
106
104
|
};
|
|
107
105
|
}, [api, apiUrl, appUrl, tenantId]);
|
|
108
106
|
return /*#__PURE__*/React.createElement(QueryProvider, null, /*#__PURE__*/React.createElement(Themer, {
|
|
@@ -158,7 +156,6 @@ var SvgGoogle = function SvgGoogle(props) {
|
|
|
158
156
|
}))));
|
|
159
157
|
};
|
|
160
158
|
|
|
161
|
-
const LOGIN_PATH = 'users/oidc/google/login';
|
|
162
159
|
/**
|
|
163
160
|
* A component for a Google login button, according to their design language.
|
|
164
161
|
* This works when an identity provider is configured in the admin dashboard.
|
|
@@ -167,25 +164,18 @@ const LOGIN_PATH = 'users/oidc/google/login';
|
|
|
167
164
|
*/
|
|
168
165
|
function GoogleSSOButton(props) {
|
|
169
166
|
const {
|
|
170
|
-
|
|
167
|
+
callbackUrl
|
|
171
168
|
} = props;
|
|
172
|
-
const {
|
|
173
|
-
apiUrl
|
|
174
|
-
} = useNileConfig();
|
|
175
|
-
if (!apiUrl) {
|
|
176
|
-
// eslint-disable-next-line no-console
|
|
177
|
-
console.error('apiUrl is missing from <NileProvider />');
|
|
178
|
-
}
|
|
179
|
-
const contextHref = `${apiUrl}/${LOGIN_PATH}`;
|
|
180
|
-
const query = newTenantName ? '?newTenant=' + encodeURIComponent(newTenantName) : '';
|
|
181
|
-
const href = contextHref + query;
|
|
182
169
|
return /*#__PURE__*/React.createElement(Box, {
|
|
183
|
-
component: "a",
|
|
184
|
-
href: href,
|
|
185
170
|
display: "flex",
|
|
186
171
|
flex: 1,
|
|
187
172
|
sx: {
|
|
188
173
|
textDecoration: 'none'
|
|
174
|
+
},
|
|
175
|
+
onClick: () => {
|
|
176
|
+
react.signIn('google', {
|
|
177
|
+
callbackUrl
|
|
178
|
+
});
|
|
189
179
|
}
|
|
190
180
|
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Button, {
|
|
191
181
|
sx: {
|
|
@@ -324,6 +314,7 @@ function CheckGroup(props) {
|
|
|
324
314
|
exports.FormAttributeType = void 0;
|
|
325
315
|
(function (AttributeType) {
|
|
326
316
|
AttributeType["Text"] = "text";
|
|
317
|
+
AttributeType["Email"] = "email";
|
|
327
318
|
AttributeType["Password"] = "password";
|
|
328
319
|
AttributeType["Select"] = "select";
|
|
329
320
|
AttributeType["Number"] = "number";
|
|
@@ -427,7 +418,8 @@ function SimpleForm(props) {
|
|
|
427
418
|
orientation: "horizontal",
|
|
428
419
|
sx: {
|
|
429
420
|
alignItems: 'center'
|
|
430
|
-
}
|
|
421
|
+
},
|
|
422
|
+
required: attr.required
|
|
431
423
|
}, /*#__PURE__*/React.createElement(Box, null, /*#__PURE__*/React.createElement(Labler, {
|
|
432
424
|
error: error,
|
|
433
425
|
attr: attr
|
|
@@ -470,7 +462,8 @@ function SimpleForm(props) {
|
|
|
470
462
|
case exports.FormAttributeType.Select:
|
|
471
463
|
return /*#__PURE__*/React.createElement(FormControl, {
|
|
472
464
|
key: display.key,
|
|
473
|
-
id: display.id
|
|
465
|
+
id: display.id,
|
|
466
|
+
required: attr.required
|
|
474
467
|
}, /*#__PURE__*/React.createElement(Labler, {
|
|
475
468
|
error: error,
|
|
476
469
|
attr: attr
|
|
@@ -510,7 +503,8 @@ function SimpleForm(props) {
|
|
|
510
503
|
case exports.FormAttributeType.Password:
|
|
511
504
|
return /*#__PURE__*/React.createElement(FormControl, {
|
|
512
505
|
key: display.key,
|
|
513
|
-
id: display.id
|
|
506
|
+
id: display.id,
|
|
507
|
+
required: attr.required
|
|
514
508
|
}, /*#__PURE__*/React.createElement(Labler, {
|
|
515
509
|
error: error,
|
|
516
510
|
attr: attr
|
|
@@ -524,7 +518,8 @@ function SimpleForm(props) {
|
|
|
524
518
|
case exports.FormAttributeType.Number:
|
|
525
519
|
return /*#__PURE__*/React.createElement(FormControl, {
|
|
526
520
|
key: display.key,
|
|
527
|
-
id: display.id
|
|
521
|
+
id: display.id,
|
|
522
|
+
required: attr.required
|
|
528
523
|
}, /*#__PURE__*/React.createElement(Labler, {
|
|
529
524
|
error: error,
|
|
530
525
|
attr: attr
|
|
@@ -539,7 +534,8 @@ function SimpleForm(props) {
|
|
|
539
534
|
default:
|
|
540
535
|
return /*#__PURE__*/React.createElement(FormControl, {
|
|
541
536
|
key: display.key,
|
|
542
|
-
id: display.id
|
|
537
|
+
id: display.id,
|
|
538
|
+
required: attr.required
|
|
543
539
|
}, /*#__PURE__*/React.createElement(Labler, {
|
|
544
540
|
error: error,
|
|
545
541
|
attr: attr
|
|
@@ -577,24 +573,33 @@ function SignUpForm(props) {
|
|
|
577
573
|
const mutation = reactQuery.useMutation(async _data => {
|
|
578
574
|
setError(undefined);
|
|
579
575
|
const possibleData = beforeMutate && beforeMutate(_data);
|
|
580
|
-
const data =
|
|
576
|
+
const data = {
|
|
577
|
+
..._data,
|
|
578
|
+
...possibleData
|
|
579
|
+
};
|
|
581
580
|
const {
|
|
581
|
+
name,
|
|
582
|
+
givenName,
|
|
583
|
+
familyName,
|
|
584
|
+
picture,
|
|
582
585
|
email,
|
|
583
586
|
password,
|
|
584
|
-
|
|
585
|
-
newTenant,
|
|
587
|
+
newTenantName,
|
|
586
588
|
...metadata
|
|
587
589
|
} = data;
|
|
588
590
|
if (Object.keys(metadata).length > 0) {
|
|
589
591
|
// eslint-disable-next-line no-console
|
|
590
592
|
console.warn('additional metadata not supported yet.');
|
|
591
593
|
}
|
|
592
|
-
return api.
|
|
593
|
-
|
|
594
|
+
return await api.users.createUser({
|
|
595
|
+
createBasicUserRequest: {
|
|
594
596
|
email,
|
|
595
597
|
password,
|
|
596
|
-
|
|
597
|
-
|
|
598
|
+
name,
|
|
599
|
+
familyName,
|
|
600
|
+
picture,
|
|
601
|
+
givenName,
|
|
602
|
+
newTenantName
|
|
598
603
|
}
|
|
599
604
|
});
|
|
600
605
|
}, {
|
|
@@ -608,7 +613,7 @@ function SignUpForm(props) {
|
|
|
608
613
|
const mainAttributes = [{
|
|
609
614
|
name: 'email',
|
|
610
615
|
label: 'Email',
|
|
611
|
-
type: exports.FormAttributeType.
|
|
616
|
+
type: exports.FormAttributeType.Email,
|
|
612
617
|
defaultValue: '',
|
|
613
618
|
required: true
|
|
614
619
|
}, {
|
|
@@ -634,7 +639,7 @@ function SignUpForm(props) {
|
|
|
634
639
|
}));
|
|
635
640
|
}
|
|
636
641
|
|
|
637
|
-
function
|
|
642
|
+
function SignInForm(props) {
|
|
638
643
|
const [error, setError] = React.useState();
|
|
639
644
|
const {
|
|
640
645
|
attributes,
|
|
@@ -642,14 +647,11 @@ function LoginForm(props) {
|
|
|
642
647
|
onError,
|
|
643
648
|
beforeMutate
|
|
644
649
|
} = props;
|
|
645
|
-
const api = useApi();
|
|
646
650
|
const mutation = reactQuery.useMutation(async _data => {
|
|
647
651
|
setError(undefined);
|
|
648
652
|
const possibleData = beforeMutate && beforeMutate(_data);
|
|
649
653
|
const data = possibleData ?? _data;
|
|
650
|
-
|
|
651
|
-
loginRequest: data
|
|
652
|
-
});
|
|
654
|
+
react.signIn('credentials', data);
|
|
653
655
|
}, {
|
|
654
656
|
onSuccess,
|
|
655
657
|
onError
|
|
@@ -684,78 +686,7 @@ function LoginForm(props) {
|
|
|
684
686
|
}));
|
|
685
687
|
}
|
|
686
688
|
|
|
687
|
-
|
|
688
|
-
const {
|
|
689
|
-
attributes,
|
|
690
|
-
onSuccess,
|
|
691
|
-
onError,
|
|
692
|
-
beforeMutate,
|
|
693
|
-
nextButtonText = 'Next',
|
|
694
|
-
loginButtonText = 'Log in',
|
|
695
|
-
disableSSO = false
|
|
696
|
-
} = props;
|
|
697
|
-
const api = useApi();
|
|
698
|
-
const [buttonText, setButtonText] = React.useState(disableSSO ? loginButtonText : nextButtonText);
|
|
699
|
-
const mutation = reactQuery.useMutation(async _data => {
|
|
700
|
-
const possibleData = beforeMutate && beforeMutate(_data);
|
|
701
|
-
const data = possibleData ?? _data;
|
|
702
|
-
return await api.auth.login({
|
|
703
|
-
loginRequest: {
|
|
704
|
-
email: data.email,
|
|
705
|
-
password: data.password
|
|
706
|
-
},
|
|
707
|
-
sso: !disableSSO
|
|
708
|
-
});
|
|
709
|
-
}, {
|
|
710
|
-
onSuccess: (token, data) => {
|
|
711
|
-
if (token) {
|
|
712
|
-
if (token?.redirectURI) {
|
|
713
|
-
window.location.href = token.redirectURI;
|
|
714
|
-
} else if (buttonText !== loginButtonText) {
|
|
715
|
-
setButtonText(loginButtonText);
|
|
716
|
-
} else {
|
|
717
|
-
onSuccess && onSuccess(token, data);
|
|
718
|
-
}
|
|
719
|
-
}
|
|
720
|
-
},
|
|
721
|
-
onError: (error, data) => {
|
|
722
|
-
// it is possible SSO failed, so only show errors on if the password is available
|
|
723
|
-
if (buttonText === loginButtonText) {
|
|
724
|
-
onError && onError(error, data);
|
|
725
|
-
} else {
|
|
726
|
-
setButtonText(loginButtonText);
|
|
727
|
-
}
|
|
728
|
-
}
|
|
729
|
-
});
|
|
730
|
-
const completeAttributes = React.useMemo(() => {
|
|
731
|
-
const mainAttributes = [{
|
|
732
|
-
name: 'email',
|
|
733
|
-
label: 'Email',
|
|
734
|
-
type: exports.FormAttributeType.Text,
|
|
735
|
-
defaultValue: '',
|
|
736
|
-
required: true
|
|
737
|
-
}];
|
|
738
|
-
if (buttonText === loginButtonText) {
|
|
739
|
-
mainAttributes.push({
|
|
740
|
-
name: 'password',
|
|
741
|
-
label: 'Password',
|
|
742
|
-
type: exports.FormAttributeType.Password,
|
|
743
|
-
defaultValue: '',
|
|
744
|
-
required: true
|
|
745
|
-
});
|
|
746
|
-
}
|
|
747
|
-
if (attributes && attributes.length > 0) {
|
|
748
|
-
return mainAttributes.concat(attributes);
|
|
749
|
-
}
|
|
750
|
-
return mainAttributes;
|
|
751
|
-
}, [attributes, buttonText, loginButtonText]);
|
|
752
|
-
return /*#__PURE__*/React.createElement(SimpleForm, {
|
|
753
|
-
mutation: mutation,
|
|
754
|
-
buttonText: buttonText,
|
|
755
|
-
attributes: completeAttributes
|
|
756
|
-
});
|
|
757
|
-
}
|
|
758
|
-
|
|
689
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
759
690
|
function AddUser(props) {
|
|
760
691
|
const {
|
|
761
692
|
open,
|
|
@@ -781,7 +712,7 @@ function AddUser(props) {
|
|
|
781
712
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
782
713
|
}, [email]);
|
|
783
714
|
const mutation = reactQuery.useMutation(data => api.users.createTenantUser({
|
|
784
|
-
|
|
715
|
+
createBasicUserRequest: data,
|
|
785
716
|
tenantId: String(tenantId)
|
|
786
717
|
}), {
|
|
787
718
|
onSuccess(data) {
|
|
@@ -970,7 +901,7 @@ function UserList(props) {
|
|
|
970
901
|
buttonText = 'Add a user',
|
|
971
902
|
onUserCreateSuccess,
|
|
972
903
|
slots,
|
|
973
|
-
include = ['email', '
|
|
904
|
+
include = ['email', 'preferredName']
|
|
974
905
|
} = props;
|
|
975
906
|
const dataGridSx = {
|
|
976
907
|
width: '100%',
|
|
@@ -992,242 +923,12 @@ function UserList(props) {
|
|
|
992
923
|
}));
|
|
993
924
|
}
|
|
994
925
|
|
|
995
|
-
|
|
996
|
-
const {
|
|
997
|
-
config,
|
|
998
|
-
providerName,
|
|
999
|
-
onSuccess,
|
|
1000
|
-
onError,
|
|
1001
|
-
allowEdit = true,
|
|
1002
|
-
configurationGuide
|
|
1003
|
-
} = props;
|
|
1004
|
-
const api = useApi();
|
|
1005
|
-
const [loading, setLoading] = React.useState(false);
|
|
1006
|
-
const [success, setSuccess] = React.useState(false);
|
|
1007
|
-
const [optimisticConfig, setConfig] = React.useState(config);
|
|
1008
|
-
const timer = React.useRef();
|
|
1009
|
-
const attributes = React.useMemo(() => {
|
|
1010
|
-
const attributes = [{
|
|
1011
|
-
name: 'enabled',
|
|
1012
|
-
label: 'Allow Okta logins',
|
|
1013
|
-
type: exports.FormAttributeType.Switch,
|
|
1014
|
-
defaultValue: optimisticConfig?.enabled === true,
|
|
1015
|
-
options: [{
|
|
1016
|
-
label: 'Enabled'
|
|
1017
|
-
}, {
|
|
1018
|
-
label: 'Disabled'
|
|
1019
|
-
}],
|
|
1020
|
-
disabled: !allowEdit
|
|
1021
|
-
}, {
|
|
1022
|
-
name: 'clientId',
|
|
1023
|
-
label: 'Client id',
|
|
1024
|
-
type: exports.FormAttributeType.Text,
|
|
1025
|
-
defaultValue: optimisticConfig?.clientId ?? '',
|
|
1026
|
-
required: true,
|
|
1027
|
-
disabled: !allowEdit
|
|
1028
|
-
}, {
|
|
1029
|
-
name: 'configUrl',
|
|
1030
|
-
label: 'Config url',
|
|
1031
|
-
type: exports.FormAttributeType.Text,
|
|
1032
|
-
defaultValue: optimisticConfig?.configUrl ?? '',
|
|
1033
|
-
helpText: 'The URL of the .well-known/openid-configuration for the identity provider',
|
|
1034
|
-
required: true,
|
|
1035
|
-
disabled: !allowEdit
|
|
1036
|
-
}, {
|
|
1037
|
-
name: 'emailDomains',
|
|
1038
|
-
label: 'Email domains',
|
|
1039
|
-
type: exports.FormAttributeType.Text,
|
|
1040
|
-
defaultValue: optimisticConfig?.emailDomains?.join(', ') ?? '',
|
|
1041
|
-
required: true,
|
|
1042
|
-
helpText: 'A comma seperated list of email domains (yourDomain.com) to be used',
|
|
1043
|
-
disabled: !allowEdit
|
|
1044
|
-
}];
|
|
1045
|
-
if (!optimisticConfig?.clientId) {
|
|
1046
|
-
attributes.splice(2, 0, {
|
|
1047
|
-
name: 'clientSecret',
|
|
1048
|
-
label: 'Client secret',
|
|
1049
|
-
type: exports.FormAttributeType.Password,
|
|
1050
|
-
defaultValue: '',
|
|
1051
|
-
required: true,
|
|
1052
|
-
disabled: !allowEdit
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
return attributes;
|
|
1056
|
-
}, [allowEdit, optimisticConfig?.clientId, optimisticConfig?.configUrl, optimisticConfig?.emailDomains, optimisticConfig?.enabled]);
|
|
1057
|
-
const handleTimer = () => {
|
|
1058
|
-
if (timer.current) {
|
|
1059
|
-
clearTimeout(timer.current);
|
|
1060
|
-
}
|
|
1061
|
-
timer.current = setTimeout(() => {
|
|
1062
|
-
setSuccess(false);
|
|
1063
|
-
}, 3000);
|
|
1064
|
-
};
|
|
1065
|
-
const mutation = reactQuery.useMutation(ssoRequest => {
|
|
1066
|
-
setLoading(true);
|
|
1067
|
-
const payload = {
|
|
1068
|
-
providerName: providerName.toLowerCase(),
|
|
1069
|
-
updateProviderRequest: {
|
|
1070
|
-
...ssoRequest,
|
|
1071
|
-
emailDomains: ssoRequest.emailDomains.split(',')
|
|
1072
|
-
}
|
|
1073
|
-
};
|
|
1074
|
-
if (optimisticConfig != null) {
|
|
1075
|
-
return api.auth.updateProvider(payload);
|
|
1076
|
-
} else {
|
|
1077
|
-
return api.auth.createProvider(payload);
|
|
1078
|
-
}
|
|
1079
|
-
}, {
|
|
1080
|
-
onSuccess: (data, vars) => {
|
|
1081
|
-
setConfig(data);
|
|
1082
|
-
setSuccess(true);
|
|
1083
|
-
onSuccess && onSuccess(data, vars);
|
|
1084
|
-
},
|
|
1085
|
-
onError,
|
|
1086
|
-
onSettled: (data, error, vars) => {
|
|
1087
|
-
setLoading(false);
|
|
1088
|
-
handleTimer();
|
|
1089
|
-
if (!data) {
|
|
1090
|
-
if (!error || error?.message.includes('Unterminated string')) {
|
|
1091
|
-
// something unexpected happened on the BE, but it's non-fatal
|
|
1092
|
-
setConfig({
|
|
1093
|
-
enabled: vars.enabled,
|
|
1094
|
-
clientId: vars.clientId,
|
|
1095
|
-
configUrl: vars.configUrl,
|
|
1096
|
-
emailDomains: vars.emailDomains.split(', ')
|
|
1097
|
-
});
|
|
1098
|
-
}
|
|
1099
|
-
setSuccess(true);
|
|
1100
|
-
onSuccess && onSuccess(data, vars);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
});
|
|
1104
|
-
React.useEffect(() => {
|
|
1105
|
-
});
|
|
1106
|
-
return /*#__PURE__*/React.createElement(Stack, {
|
|
1107
|
-
gap: 2,
|
|
1108
|
-
position: "relative"
|
|
1109
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
1110
|
-
level: "h4"
|
|
1111
|
-
}, "Step 1"), configurationGuide, /*#__PURE__*/React.createElement(Typography, {
|
|
1112
|
-
level: "h4"
|
|
1113
|
-
}, "Step 2"), /*#__PURE__*/React.createElement(SimpleForm, {
|
|
1114
|
-
mutation: mutation,
|
|
1115
|
-
buttonText: "Update",
|
|
1116
|
-
attributes: attributes,
|
|
1117
|
-
loading: loading,
|
|
1118
|
-
successMessage: /*#__PURE__*/React.createElement(Alert, {
|
|
1119
|
-
color: "success",
|
|
1120
|
-
sx: {
|
|
1121
|
-
opacity: success ? 1 : 0,
|
|
1122
|
-
transition: 'opacity 200ms',
|
|
1123
|
-
height: '0.9rem'
|
|
1124
|
-
},
|
|
1125
|
-
startDecorator: /*#__PURE__*/React.createElement(CheckCircleOutlined, null)
|
|
1126
|
-
}, /*#__PURE__*/React.createElement(Typography, {
|
|
1127
|
-
textAlign: "center",
|
|
1128
|
-
fontSize: "sm"
|
|
1129
|
-
}, "Provider updated"))
|
|
1130
|
-
}));
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
function ConfigGuide({
|
|
1134
|
-
callbackUrl
|
|
1135
|
-
}) {
|
|
1136
|
-
const [copied, setCopied] = React.useState(false);
|
|
1137
|
-
const timer = React.useRef();
|
|
1138
|
-
React.useEffect(() => {
|
|
1139
|
-
if (timer.current) {
|
|
1140
|
-
clearTimeout(timer.current);
|
|
1141
|
-
}
|
|
1142
|
-
timer.current = setTimeout(() => {
|
|
1143
|
-
setCopied(false);
|
|
1144
|
-
}, 3250);
|
|
1145
|
-
}, [copied]);
|
|
1146
|
-
return /*#__PURE__*/React.createElement(Stack, {
|
|
1147
|
-
gap: 2
|
|
1148
|
-
}, /*#__PURE__*/React.createElement(Typography, null, "In order for Okta to redirect properly, provide the following URL as the", ' ', /*#__PURE__*/React.createElement(Box, {
|
|
1149
|
-
component: "span",
|
|
1150
|
-
sx: {
|
|
1151
|
-
fontFamily: 'monospace'
|
|
1152
|
-
}
|
|
1153
|
-
}, "Sign-in redirect URIs"), ' ', "in the admin configuration of your application."), /*#__PURE__*/React.createElement(Input, {
|
|
1154
|
-
onClick: async () => {
|
|
1155
|
-
if (callbackUrl) {
|
|
1156
|
-
await navigator.clipboard.writeText(callbackUrl);
|
|
1157
|
-
setCopied(true);
|
|
1158
|
-
}
|
|
1159
|
-
},
|
|
1160
|
-
sx: theme => ({
|
|
1161
|
-
input: {
|
|
1162
|
-
cursor: 'pointer'
|
|
1163
|
-
},
|
|
1164
|
-
span: {
|
|
1165
|
-
cursor: 'pointer'
|
|
1166
|
-
},
|
|
1167
|
-
'&:hover svg': {
|
|
1168
|
-
'--Icon-color': theme.palette.primary[500]
|
|
1169
|
-
}
|
|
1170
|
-
}),
|
|
1171
|
-
value: callbackUrl,
|
|
1172
|
-
readOnly: true,
|
|
1173
|
-
endDecorator: /*#__PURE__*/React.createElement(Tooltip, {
|
|
1174
|
-
title: "Copy Okta redirect URL"
|
|
1175
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
1176
|
-
position: "relative",
|
|
1177
|
-
width: copied ? '82px' : '24px',
|
|
1178
|
-
height: "24px"
|
|
1179
|
-
}, /*#__PURE__*/React.createElement(Box, {
|
|
1180
|
-
position: "absolute",
|
|
1181
|
-
top: "0",
|
|
1182
|
-
left: "0",
|
|
1183
|
-
sx: {
|
|
1184
|
-
opacity: copied ? 0 : 1,
|
|
1185
|
-
transition: 'opacity 300ms'
|
|
1186
|
-
}
|
|
1187
|
-
}, /*#__PURE__*/React.createElement(CopyAll, null)), /*#__PURE__*/React.createElement(Box, {
|
|
1188
|
-
position: "absolute",
|
|
1189
|
-
top: "0",
|
|
1190
|
-
left: "0",
|
|
1191
|
-
sx: {
|
|
1192
|
-
opacity: !copied ? 0 : 1,
|
|
1193
|
-
transition: 'opacity 300ms'
|
|
1194
|
-
}
|
|
1195
|
-
}, /*#__PURE__*/React.createElement(Stack, {
|
|
1196
|
-
direction: "row",
|
|
1197
|
-
gap: 1
|
|
1198
|
-
}, /*#__PURE__*/React.createElement(CheckCircleOutlined, null), /*#__PURE__*/React.createElement(Typography, {
|
|
1199
|
-
color: "primary"
|
|
1200
|
-
}, "Copied!")))))
|
|
1201
|
-
}));
|
|
1202
|
-
}
|
|
1203
|
-
function Okta(props) {
|
|
1204
|
-
const {
|
|
1205
|
-
callbackUrl,
|
|
1206
|
-
providers,
|
|
1207
|
-
...remaining
|
|
1208
|
-
} = props;
|
|
1209
|
-
if (!providers) {
|
|
1210
|
-
return null;
|
|
1211
|
-
}
|
|
1212
|
-
const config = providers?.find(provider => provider.provider === 'okta');
|
|
1213
|
-
return /*#__PURE__*/React.createElement(BaseSSOForm, {
|
|
1214
|
-
...remaining,
|
|
1215
|
-
config: config,
|
|
1216
|
-
providerName: "Okta",
|
|
1217
|
-
configurationGuide: /*#__PURE__*/React.createElement(ConfigGuide, {
|
|
1218
|
-
callbackUrl: callbackUrl
|
|
1219
|
-
})
|
|
1220
|
-
});
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
exports.GoogleLoginButton = GoogleSSOButton;
|
|
926
|
+
exports.Google = GoogleSSOButton;
|
|
1224
927
|
exports.NileProvider = NileProvider;
|
|
1225
|
-
exports.
|
|
1226
|
-
exports.
|
|
1227
|
-
exports.SingleSignOnForm = SingleSignOnForm;
|
|
1228
|
-
exports.UserLoginForm = LoginForm;
|
|
1229
|
-
exports.UserSignupForm = SignUpForm;
|
|
928
|
+
exports.SignInForm = SignInForm;
|
|
929
|
+
exports.SignUpForm = SignUpForm;
|
|
1230
930
|
exports.UserTenantList = UserList;
|
|
931
|
+
exports.useApi = useApi;
|
|
1231
932
|
Object.keys(react).forEach(function (k) {
|
|
1232
933
|
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
1233
934
|
enumerable: true,
|