@evoke-platform/context 1.3.0-dev.7 → 1.3.0-testing.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/README.md CHANGED
@@ -17,7 +17,6 @@ available and no further installation is necessary.
17
17
 
18
18
  - [Working With Objects](#working-with-objects)
19
19
  - [REST API Calls](#rest-api-calls)
20
- - [Authentication Context](#authentication-context)
21
20
  - [Notifications](#notifications)
22
21
 
23
22
  ### Working With Objects
@@ -223,25 +222,6 @@ absolute URL.
223
222
 
224
223
  ##### `delete(url, options)`
225
224
 
226
- ### Authentication Context
227
-
228
- - [useAuthenticationContext](#useauthenticationcontext)
229
-
230
- #### `useAuthenticationContext()`
231
-
232
- Hook to obtain the authentication context based on the current logged-in user.
233
-
234
- The authentication context includes the following property and functions.
235
-
236
- - `account` _[object]_
237
- - The account of the currently logged-in user. This includes both the user's `id` and `name`.
238
- - `logout()`
239
- - A function that logs out the currently logged-in user. The user will be redirected to Evoke's logout page upon logout.
240
- - `getAccessToken()`
241
- - A function that returns an access token that is associated to the currently logged-in user. This token can be used to make API calls to Evoke's APIs to authenticate the API call.
242
- - Note: As a general recommendation, the [ApiService](#class-apiservices) class should be used to make API calls as it will take care
243
- of appending an access token to the call.
244
-
245
225
  ### Notifications
246
226
 
247
227
  - [useNofitication](#usenotification)
@@ -30,8 +30,6 @@ export type Widget = {
30
30
  pluginId: string;
31
31
  widgetKey: string;
32
32
  colSpan: number;
33
- isSticky?: boolean;
34
- noPadding?: boolean;
35
33
  properties: Record<string, unknown>;
36
34
  };
37
35
  export type NavigationLocation = 'side' | 'top' | 'none';
@@ -9,10 +9,9 @@ export type AuthenticationContext = {
9
9
  export type UserAccount = {
10
10
  id: string;
11
11
  name?: string;
12
- lastLoginTime?: number;
13
12
  };
14
13
  export type AuthenticationContextProviderProps = {
15
- msal?: IMsalContext;
14
+ msal: IMsalContext;
16
15
  authRequest: AuthenticationRequest;
17
16
  children?: ReactNode;
18
17
  };
@@ -9,25 +9,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { jsx as _jsx } from "react/jsx-runtime";
11
11
  import { createContext, useCallback, useContext, useMemo } from 'react';
12
- import { useAuth } from 'react-oidc-context';
13
12
  const Context = createContext(undefined);
14
13
  Context.displayName = 'AuthenticationContext';
15
14
  function AuthenticationContextProvider(props) {
16
- // Auto-detect provider type based on presence of msal prop
17
- if (props.msal) {
18
- const { msal, authRequest, children } = props;
19
- return (_jsx(MsalProvider, { msal: msal, authRequest: authRequest, children: children }));
20
- }
21
- else {
22
- const { authRequest, children } = props;
23
- return _jsx(OidcProvider, { authRequest: authRequest, children: children });
24
- }
25
- }
26
- function MsalProvider({ msal, authRequest, children }) {
27
15
  var _a;
28
- if (!msal) {
29
- throw new Error('MSAL instance is required for MsalProvider');
30
- }
16
+ const { msal, authRequest, children } = props;
31
17
  const account = (_a = msal.instance.getActiveAccount()) !== null && _a !== void 0 ? _a : msal.instance.getAllAccounts()[0];
32
18
  const getAccessToken = useCallback(function () {
33
19
  return __awaiter(this, void 0, void 0, function* () {
@@ -40,81 +26,19 @@ function MsalProvider({ msal, authRequest, children }) {
40
26
  return '';
41
27
  }
42
28
  });
43
- }, [msal, authRequest, account]);
44
- const context = useMemo(() => {
45
- var _a;
46
- return account
47
- ? {
48
- account: {
49
- id: account.localAccountId,
50
- name: account.name,
51
- lastLoginTime: (_a = account.idTokenClaims) === null || _a === void 0 ? void 0 : _a.last_login_time,
52
- },
53
- logout: () => {
54
- msal.instance.logoutRedirect({
55
- account,
56
- postLogoutRedirectUri: `/logout?p=${encodeURIComponent(window.location.pathname + window.location.search)}`,
57
- });
58
- },
59
- getAccessToken,
60
- }
61
- : undefined;
62
- }, [account, msal, getAccessToken, authRequest]);
63
- return _jsx(Context.Provider, { value: context, children: children });
64
- }
65
- function OidcProvider({ authRequest, children }) {
66
- var _a, _b;
67
- // The authRequest for react-oidc is formatted slightly differently than msal.
68
- const oidcAuthRequest = {
69
- scope: (_b = (_a = authRequest.scopes) === null || _a === void 0 ? void 0 : _a.join(' ')) !== null && _b !== void 0 ? _b : 'openid profile email',
70
- extraQueryParams: authRequest.extraQueryParameters,
71
- state: authRequest.state,
72
- };
73
- const auth = useAuth();
74
- const getAccessToken = useCallback(function () {
75
- var _a, _b;
76
- return __awaiter(this, void 0, void 0, function* () {
77
- try {
78
- // With automaticSilentRenew: true, oidc-client-ts will attempt to renew the token in the background before it expires.
79
- // However, this is not guaranteed to be perfectly in sync with your API calls. Always check for expiration here and call signinSilent if needed
80
- // to ensure you get a valid token on demand.
81
- if (((_a = auth.user) === null || _a === void 0 ? void 0 : _a.access_token) && !auth.user.expired) {
82
- return auth.user.access_token;
83
- }
84
- // Token is either missing or expired - attempt silent refresh.
85
- const user = yield auth.signinSilent(oidcAuthRequest);
86
- // If signinSilent returns null, it means silent login failed
87
- if (!user) {
88
- console.log('Silent login failed, redirecting to login');
89
- auth.signinRedirect(oidcAuthRequest);
90
- return '';
91
- }
92
- return ((_b = auth.user) === null || _b === void 0 ? void 0 : _b.access_token) || '';
93
- }
94
- catch (error) {
95
- console.error('Failed to get access token:', error);
96
- // If silent refresh throws an error (e.g., network failure, missing silent_redirect_uri,
97
- // invalid session, refresh token expired, or provider returned an error), redirect to login
98
- auth.signinRedirect(oidcAuthRequest);
99
- return '';
100
- }
101
- });
102
- }, [auth, authRequest]);
103
- const context = useMemo(() => auth.isAuthenticated && auth.user
29
+ }, [msal, authRequest]);
30
+ const context = useMemo(() => account
104
31
  ? {
105
- account: {
106
- id: auth.user.profile.sub,
107
- name: auth.user.profile.name,
108
- lastLoginTime: auth.user.profile.auth_time,
109
- },
32
+ account: { id: account.localAccountId, name: account.name },
110
33
  logout: () => {
111
- auth.signoutRedirect({
112
- post_logout_redirect_uri: `/logout?p=${encodeURIComponent(window.location.pathname + window.location.search)}`,
34
+ msal.instance.logoutRedirect({
35
+ account,
36
+ postLogoutRedirectUri: `/logout?p=${encodeURIComponent(window.location.pathname + window.location.search)}`,
113
37
  });
114
38
  },
115
39
  getAccessToken,
116
40
  }
117
- : undefined, [auth, getAccessToken]);
41
+ : undefined, [account, msal, getAccessToken]);
118
42
  return _jsx(Context.Provider, { value: context, children: children });
119
43
  }
120
44
  export function useAuthenticationContext() {
@@ -1,8 +1,5 @@
1
1
  import { ApiServices, Callback } from '../api/index.js';
2
2
  import { Filter } from './filters.js';
3
- export type EvokeFormDisplayConfiguration = {
4
- submitLabel?: string;
5
- };
6
3
  export type EvokeForm = {
7
4
  id: string;
8
5
  name: string;
@@ -11,7 +8,6 @@ export type EvokeForm = {
11
8
  formObjectId?: string;
12
9
  actionId?: string;
13
10
  autosaveActionId?: string;
14
- display?: EvokeFormDisplayConfiguration;
15
11
  };
16
12
  export type BaseObjReference = {
17
13
  objectId: string;
@@ -113,7 +109,6 @@ export type InputStringValidation = StringValidation & {
113
109
  maxLength?: number;
114
110
  mask?: string;
115
111
  };
116
- export type BasicInputParameter = Omit<InputParameter, 'name' | 'required'>;
117
112
  export type InputParameter = {
118
113
  id: string;
119
114
  name?: string;
@@ -135,7 +130,6 @@ export type Action = {
135
130
  inputProperties?: ActionInput[];
136
131
  parameters?: InputParameter[];
137
132
  form?: Form;
138
- defaultFormId?: string;
139
133
  customCode?: string;
140
134
  preconditions?: object;
141
135
  };
@@ -231,7 +225,7 @@ export type ReadonlyField = {
231
225
  };
232
226
  export type InputField = {
233
227
  type: 'inputField';
234
- input: BasicInputParameter;
228
+ input: InputParameter;
235
229
  display?: DisplayConfiguration;
236
230
  documentMetadata?: Record<string, string>;
237
231
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evoke-platform/context",
3
- "version": "1.3.0-dev.7",
3
+ "version": "1.3.0-testing.0",
4
4
  "description": "Utilities that provide context to Evoke platform widgets",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -56,7 +56,6 @@
56
56
  "msw": "^1.3.1",
57
57
  "react": "^18.2.0",
58
58
  "react-dom": "^18.3.1",
59
- "react-oidc-context": "^2.4.0",
60
59
  "react-router-dom": "^6.16.0",
61
60
  "sinon": "^18.0.0",
62
61
  "typescript": "^5.3.3"
@@ -65,14 +64,12 @@
65
64
  "@azure/msal-browser": ">=2",
66
65
  "@azure/msal-react": ">=1",
67
66
  "react": ">=18",
68
- "react-oidc-context": ">=2",
69
67
  "react-router-dom": ">=6"
70
68
  },
71
69
  "dependencies": {
72
70
  "@isaacs/ttlcache": "^1.4.1",
73
71
  "@microsoft/signalr": "^7.0.12",
74
72
  "axios": "^1.7.9",
75
- "oidc-client-ts": "^3.3.0",
76
73
  "uuid": "^9.0.1"
77
74
  }
78
75
  }