@intra-mart/smartlime 2.0.0-dev.20241125 → 2.0.0-dev.20241210
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/eslint.config.mjs +50 -0
- package/lib/_shared/renderTarget.d.ts +11 -11
- package/lib/_shared/renderTarget.js +2 -2
- package/lib/packages/Me/Context.d.ts +0 -1
- package/lib/packages/Me/index.d.ts +0 -1
- package/lib/packages/OAuth/Context.d.ts +1 -14
- package/lib/packages/OAuth/hooks/index.d.ts +0 -1
- package/lib/packages/OAuth/hooks/index.js +0 -1
- package/lib/packages/OAuth/hooks/useAuthState.d.ts +1 -1
- package/lib/packages/OAuth/hooks/useAuthStateEffect.d.ts +1 -1
- package/lib/packages/OAuth/hooks/useStartAuth.d.ts +1 -1
- package/lib/packages/OAuth/index.d.ts +13 -9
- package/lib/packages/OAuth/index.js +42 -70
- package/lib/packages/Search/Context.d.ts +0 -1
- package/lib/packages/Search/hooks/useIMSearch.d.ts +1 -1
- package/lib/packages/Search/index.d.ts +0 -1
- package/lib/packages/Session/Context.d.ts +0 -1
- package/lib/packages/Session/hooks/useSession.d.ts +0 -1
- package/lib/packages/Session/hooks/useSessionState.d.ts +0 -1
- package/lib/packages/Session/index.d.ts +0 -1
- package/lib/packages/Smartlime/NotSearchPropError.d.ts +0 -1
- package/lib/packages/Smartlime/index.d.ts +0 -1
- package/lib/packages/Tenant/Context.d.ts +0 -1
- package/lib/packages/Tenant/index.d.ts +0 -1
- package/lib/packages/WebView/hooks/useHackSearchUI.d.ts +0 -1
- package/lib/utils/mergeRef.d.ts +1 -2
- package/package.json +22 -22
- package/lib/packages/OAuth/hooks/useAuthError.d.ts +0 -2
- package/lib/packages/OAuth/hooks/useAuthError.js +0 -15
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import tsParser from '@typescript-eslint/parser';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import js from '@eslint/js';
|
|
5
|
+
import { FlatCompat } from '@eslint/eslintrc';
|
|
6
|
+
|
|
7
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
8
|
+
const __dirname = path.dirname(__filename);
|
|
9
|
+
const compat = new FlatCompat({
|
|
10
|
+
baseDirectory: __dirname,
|
|
11
|
+
recommendedConfig: js.configs.recommended,
|
|
12
|
+
allConfig: js.configs.all,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
export default [
|
|
16
|
+
...compat.extends(
|
|
17
|
+
'plugin:react/recommended',
|
|
18
|
+
'plugin:@typescript-eslint/recommended',
|
|
19
|
+
'prettier'
|
|
20
|
+
),
|
|
21
|
+
{
|
|
22
|
+
languageOptions: {
|
|
23
|
+
parser: tsParser,
|
|
24
|
+
ecmaVersion: 2020,
|
|
25
|
+
sourceType: 'module',
|
|
26
|
+
|
|
27
|
+
parserOptions: {
|
|
28
|
+
ecmaFeatures: {
|
|
29
|
+
jsx: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
settings: {
|
|
35
|
+
react: {
|
|
36
|
+
version: 'detect',
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
rules: {
|
|
41
|
+
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
|
42
|
+
'@typescript-eslint/ban-ts-comment': 'off',
|
|
43
|
+
'@typescript-eslint/no-empty-function': 'off',
|
|
44
|
+
'react/react-in-jsx-scope': 'off',
|
|
45
|
+
'react/prop-types': 'off',
|
|
46
|
+
'react/display-name': 'off',
|
|
47
|
+
'react/jsx-key': 'off',
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
];
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
type ForceRender
|
|
2
|
-
export declare const createRenderTarget:
|
|
3
|
-
addEventListener: (callback: ForceRender
|
|
4
|
-
removeEventListener: (callback: ForceRender
|
|
5
|
-
dispatch: (
|
|
1
|
+
type ForceRender = () => void;
|
|
2
|
+
export declare const createRenderTarget: () => {
|
|
3
|
+
addEventListener: (callback: ForceRender) => void;
|
|
4
|
+
removeEventListener: (callback: ForceRender) => void;
|
|
5
|
+
dispatch: () => void;
|
|
6
6
|
};
|
|
7
|
-
export type CreateRenderTarget
|
|
8
|
-
export type RenderTarget
|
|
9
|
-
export declare const useRenderTarget:
|
|
10
|
-
addEventListener: (callback: ForceRender
|
|
11
|
-
removeEventListener: (callback: ForceRender
|
|
12
|
-
dispatch: (
|
|
7
|
+
export type CreateRenderTarget = typeof createRenderTarget;
|
|
8
|
+
export type RenderTarget = ReturnType<CreateRenderTarget>;
|
|
9
|
+
export declare const useRenderTarget: () => {
|
|
10
|
+
addEventListener: (callback: ForceRender) => void;
|
|
11
|
+
removeEventListener: (callback: ForceRender) => void;
|
|
12
|
+
dispatch: () => void;
|
|
13
13
|
};
|
|
14
14
|
export {};
|
|
@@ -12,11 +12,11 @@ export const createRenderTarget = () => {
|
|
|
12
12
|
}
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
const dispatch = (
|
|
15
|
+
const dispatch = () => {
|
|
16
16
|
for (let i = 0, l = listenerList.length; i < l; i++) {
|
|
17
17
|
const listener = listenerList[i];
|
|
18
18
|
if (listener)
|
|
19
|
-
listener(
|
|
19
|
+
listener();
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
return {
|
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { AuthState, StartAuthResult } from '.';
|
|
2
2
|
import { RenderTarget } from '../../_shared/renderTarget';
|
|
3
|
-
import { AuthSessionResult } from 'expo-auth-session';
|
|
4
|
-
import { IMOAuthError } from './IMOAuthError';
|
|
5
|
-
export type AuthState = 'initializing' | 'unauthorized' | 'authorized';
|
|
6
|
-
export type StartAuthResult = {
|
|
7
|
-
readonly type: 'cancel' | 'dismiss' | 'opened' | 'locked' | 'error';
|
|
8
|
-
readonly detail: AuthSessionResult;
|
|
9
|
-
} | {
|
|
10
|
-
readonly type: 'success';
|
|
11
|
-
} | {
|
|
12
|
-
readonly type: 'exception';
|
|
13
|
-
readonly exceptionDetail: unknown;
|
|
14
|
-
};
|
|
15
3
|
export interface OAuthContext {
|
|
16
4
|
getAuthState: () => AuthState;
|
|
17
5
|
getToken: () => string | null;
|
|
@@ -21,6 +9,5 @@ export interface OAuthContext {
|
|
|
21
9
|
startAuth: () => Promise<StartAuthResult>;
|
|
22
10
|
tokenRenderTarget: RenderTarget;
|
|
23
11
|
authStateRenderTarget: RenderTarget;
|
|
24
|
-
authErrorRenderTarget: RenderTarget<IMOAuthError>;
|
|
25
12
|
}
|
|
26
13
|
export declare const Context: import("react").Context<OAuthContext | null>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Context as DefaultContext } from '../Context';
|
|
2
|
-
export declare const useAuthState: (Context?: typeof DefaultContext) => import("
|
|
2
|
+
export declare const useAuthState: (Context?: typeof DefaultContext) => import("..").AuthState;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { Context as DefaultContext } from '../Context';
|
|
2
|
-
export declare const useStartAuth: (Context?: typeof DefaultContext) => () => Promise<import("
|
|
2
|
+
export declare const useStartAuth: (Context?: typeof DefaultContext) => () => Promise<import("..").StartAuthResult>;
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
import { Prompt } from 'expo-auth-session';
|
|
3
|
-
import * as SecureStore from 'expo-secure-store';
|
|
1
|
+
import { AuthSessionResult, Prompt } from 'expo-auth-session';
|
|
4
2
|
import { Context as DefaultContext } from './Context';
|
|
3
|
+
export type AuthState = 'initializing' | 'unauthorized' | 'authorized';
|
|
5
4
|
export type TokenState = {
|
|
6
5
|
baseUrl: string;
|
|
7
6
|
accessToken: string;
|
|
8
7
|
refreshToken?: string;
|
|
9
8
|
expirationDate?: number;
|
|
10
9
|
};
|
|
10
|
+
export type StartAuthResult = {
|
|
11
|
+
readonly type: 'cancel' | 'dismiss' | 'opened' | 'locked' | 'error';
|
|
12
|
+
readonly detail: AuthSessionResult;
|
|
13
|
+
} | {
|
|
14
|
+
readonly type: 'success';
|
|
15
|
+
} | {
|
|
16
|
+
readonly type: 'exception';
|
|
17
|
+
readonly exceptionDetail: unknown;
|
|
18
|
+
};
|
|
11
19
|
export declare const IMPrompt: {
|
|
12
20
|
readonly Login: Prompt.Login;
|
|
13
21
|
readonly None: Prompt.None;
|
|
@@ -20,16 +28,12 @@ interface RequestConfig {
|
|
|
20
28
|
state?: string;
|
|
21
29
|
prompt?: Prompt.Login | Prompt.None;
|
|
22
30
|
}
|
|
23
|
-
interface SecureStoreConfig {
|
|
24
|
-
storeKey?: string;
|
|
25
|
-
keychainAccessible?: SecureStore.KeychainAccessibilityConstant;
|
|
26
|
-
}
|
|
27
31
|
interface IMOAuthProps {
|
|
28
32
|
children: JSX.Element;
|
|
29
33
|
requestConfig: RequestConfig;
|
|
30
34
|
remainingTimeToRunRefresh?: number;
|
|
31
|
-
|
|
35
|
+
storageKey?: string;
|
|
32
36
|
oauthContext?: typeof DefaultContext;
|
|
33
37
|
}
|
|
34
|
-
export declare const IMOAuth: ({ children, requestConfig, remainingTimeToRunRefresh,
|
|
38
|
+
export declare const IMOAuth: ({ children, requestConfig, remainingTimeToRunRefresh, storageKey, oauthContext, }: IMOAuthProps) => import("react").JSX.Element;
|
|
35
39
|
export {};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { exchangeCodeAsync, loadAsync, Prompt, refreshAsync, } from 'expo-auth-session';
|
|
2
1
|
import * as SecureStore from 'expo-secure-store';
|
|
3
|
-
import
|
|
4
|
-
import { useCallback,
|
|
5
|
-
import {
|
|
2
|
+
import { exchangeCodeAsync, loadAsync, Prompt, refreshAsync, } from 'expo-auth-session';
|
|
3
|
+
import { useCallback, useLayoutEffect, useMemo, useRef, } from 'react';
|
|
4
|
+
import { Context as DefaultContext } from './Context';
|
|
5
|
+
import { IMOAuthError } from './IMOAuthError';
|
|
6
6
|
import { useRenderTarget } from '../../_shared/renderTarget';
|
|
7
|
+
import { useIMBaseUrl } from '../..';
|
|
7
8
|
import { join } from '../../utils/path';
|
|
8
|
-
import
|
|
9
|
-
import { IMOAuthError } from './IMOAuthError';
|
|
9
|
+
import * as WebBrowser from 'expo-web-browser';
|
|
10
10
|
WebBrowser.maybeCompleteAuthSession();
|
|
11
11
|
const SUCCESS = 'success';
|
|
12
12
|
const EXCEPTION = 'exception';
|
|
@@ -51,17 +51,10 @@ const useDiscovery = () => {
|
|
|
51
51
|
};
|
|
52
52
|
}, [encodedBaseUrl]);
|
|
53
53
|
};
|
|
54
|
-
const
|
|
55
|
-
const storeKey = secureStore?.storeKey;
|
|
56
|
-
const keychainAccessible = secureStore?.keychainAccessible;
|
|
54
|
+
const useStorageKey = (storageKey) => {
|
|
57
55
|
return useMemo(() => {
|
|
58
|
-
return
|
|
59
|
-
|
|
60
|
-
keychainAccessible: keychainAccessible !== void 0
|
|
61
|
-
? keychainAccessible
|
|
62
|
-
: SecureStore.WHEN_UNLOCKED,
|
|
63
|
-
};
|
|
64
|
-
}, [storeKey, keychainAccessible]);
|
|
56
|
+
return storageKey ? storageKey : DEFAULT_STORAGE_KEY;
|
|
57
|
+
}, [storageKey]);
|
|
65
58
|
};
|
|
66
59
|
const useRemainingTimeToRunRefresh = (remainingTimeToRunRefresh) => {
|
|
67
60
|
return useMemo(() => {
|
|
@@ -70,26 +63,20 @@ const useRemainingTimeToRunRefresh = (remainingTimeToRunRefresh) => {
|
|
|
70
63
|
: DEFAULT_REMAINING_TIME_TO_RUN_REFRESH;
|
|
71
64
|
}, [remainingTimeToRunRefresh]);
|
|
72
65
|
};
|
|
73
|
-
const saveTokenStorage = async (
|
|
66
|
+
const saveTokenStorage = async (storageKey, baseUrl, accessToken, refreshToken, expirationDate) => {
|
|
74
67
|
const item = {
|
|
75
68
|
baseUrl,
|
|
76
69
|
accessToken,
|
|
77
70
|
refreshToken,
|
|
78
71
|
expirationDate,
|
|
79
72
|
};
|
|
80
|
-
return await SecureStore.setItemAsync(
|
|
81
|
-
keychainAccessible: storeConfig.keychainAccessible,
|
|
82
|
-
});
|
|
73
|
+
return await SecureStore.setItemAsync(storageKey, JSON.stringify(item));
|
|
83
74
|
};
|
|
84
|
-
const deleteTokenStorage = async (
|
|
85
|
-
return await SecureStore.deleteItemAsync(
|
|
86
|
-
keychainAccessible: storeConfig.keychainAccessible,
|
|
87
|
-
});
|
|
75
|
+
const deleteTokenStorage = async (tokenStorageKey) => {
|
|
76
|
+
return await SecureStore.deleteItemAsync(tokenStorageKey);
|
|
88
77
|
};
|
|
89
|
-
const getTokenStorage = async (
|
|
90
|
-
const state = await SecureStore.getItemAsync(
|
|
91
|
-
keychainAccessible: storeConfig.keychainAccessible,
|
|
92
|
-
});
|
|
78
|
+
const getTokenStorage = async (storageKey) => {
|
|
79
|
+
const state = await SecureStore.getItemAsync(storageKey);
|
|
93
80
|
if (state == null)
|
|
94
81
|
return;
|
|
95
82
|
const result = JSON.parse(state);
|
|
@@ -129,7 +116,7 @@ const checkExpirationDateOfToken = (expirationDate, remainingTimeToRunRefresh) =
|
|
|
129
116
|
return true;
|
|
130
117
|
return false;
|
|
131
118
|
};
|
|
132
|
-
const useRefresh = (
|
|
119
|
+
const useRefresh = (storageKey, refreshTokenRef, expirationDateRef, requestConfig, discovery, setToken, destroy) => {
|
|
133
120
|
const baseUrl = useIMBaseUrl();
|
|
134
121
|
const lockedRef = useRef(false);
|
|
135
122
|
const waitingLineRef = useRef([]);
|
|
@@ -176,7 +163,7 @@ const useRefresh = (storeConfig, refreshTokenRef, expirationDateRef, requestConf
|
|
|
176
163
|
}, discovery);
|
|
177
164
|
const { accessToken, refreshToken, expiresIn } = tokenResponse;
|
|
178
165
|
const expirationDate = expiresIn ? createExpirationDate(expiresIn) : 0;
|
|
179
|
-
await saveTokenStorage(
|
|
166
|
+
await saveTokenStorage(storageKey, baseUrl, accessToken, refreshToken, expirationDate);
|
|
180
167
|
refreshTokenRef.current = refreshToken ? refreshToken : null;
|
|
181
168
|
expirationDateRef.current = expirationDate;
|
|
182
169
|
setToken(accessToken);
|
|
@@ -191,49 +178,36 @@ const useRefresh = (storeConfig, refreshTokenRef, expirationDateRef, requestConf
|
|
|
191
178
|
throw error;
|
|
192
179
|
}
|
|
193
180
|
}
|
|
194
|
-
}, [
|
|
181
|
+
}, [storageKey, requestConfig, discovery, destroy]);
|
|
195
182
|
};
|
|
196
|
-
const useStartAuth = (
|
|
183
|
+
const useStartAuth = (storageKey, remainingTimeToRunRefresh, refreshTokenRef, expirationDateRef, requestConfig, discovery, setToken, refresh, setAuthState) => {
|
|
197
184
|
const currentBaseUrl = useIMBaseUrl();
|
|
198
|
-
|
|
185
|
+
useLayoutEffect(() => {
|
|
199
186
|
(async () => {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
if (
|
|
208
|
-
|
|
209
|
-
await refresh(); // NOTE consideration of how users can catch errors thrown here.
|
|
210
|
-
}
|
|
211
|
-
else {
|
|
212
|
-
setToken(accessToken);
|
|
213
|
-
}
|
|
214
|
-
setAuthState('authorized');
|
|
187
|
+
const tokenState = await getTokenStorage(storageKey);
|
|
188
|
+
if (tokenState) {
|
|
189
|
+
const { baseUrl, accessToken, refreshToken, expirationDate } = tokenState;
|
|
190
|
+
const expired = checkExpirationDateOfToken(expirationDate ? expirationDate : 0, remainingTimeToRunRefresh);
|
|
191
|
+
refreshTokenRef.current = refreshToken ? refreshToken : null;
|
|
192
|
+
expirationDateRef.current = expirationDate ? expirationDate : null;
|
|
193
|
+
if (currentBaseUrl === baseUrl) {
|
|
194
|
+
if (expired) {
|
|
195
|
+
await refresh(); // NOTE consideration of how users can catch errors thrown here.
|
|
215
196
|
}
|
|
216
197
|
else {
|
|
217
|
-
|
|
198
|
+
setToken(accessToken);
|
|
218
199
|
}
|
|
200
|
+
setAuthState('authorized');
|
|
219
201
|
}
|
|
220
202
|
else {
|
|
221
203
|
setAuthState('unauthorized');
|
|
222
204
|
}
|
|
223
205
|
}
|
|
224
|
-
|
|
206
|
+
else {
|
|
225
207
|
setAuthState('unauthorized');
|
|
226
|
-
authErrorRenderTarget.dispatch(new IMOAuthError('an exception occurred while checking the token state.', {
|
|
227
|
-
cause: e,
|
|
228
|
-
}));
|
|
229
208
|
}
|
|
230
209
|
})();
|
|
231
|
-
}, [
|
|
232
|
-
storeConfig.storeKey,
|
|
233
|
-
storeConfig.keychainAccessible,
|
|
234
|
-
remainingTimeToRunRefresh,
|
|
235
|
-
refresh,
|
|
236
|
-
]);
|
|
210
|
+
}, [storageKey, remainingTimeToRunRefresh, refresh]);
|
|
237
211
|
const startAuth = useCallback(async () => {
|
|
238
212
|
const authRequest = await loadAsync({
|
|
239
213
|
...requestConfig,
|
|
@@ -262,7 +236,7 @@ const useStartAuth = (storeConfig, remainingTimeToRunRefresh, refreshTokenRef, e
|
|
|
262
236
|
}, discovery);
|
|
263
237
|
const { accessToken, refreshToken, expiresIn } = tokenResponse;
|
|
264
238
|
const expirationDate = expiresIn ? createExpirationDate(expiresIn) : 0;
|
|
265
|
-
await saveTokenStorage(
|
|
239
|
+
await saveTokenStorage(storageKey, currentBaseUrl, accessToken, refreshToken, expirationDate);
|
|
266
240
|
refreshTokenRef.current = refreshToken ? refreshToken : null;
|
|
267
241
|
expirationDateRef.current = expirationDate;
|
|
268
242
|
setToken(accessToken);
|
|
@@ -282,14 +256,14 @@ const useStartAuth = (storeConfig, remainingTimeToRunRefresh, refreshTokenRef, e
|
|
|
282
256
|
}, [requestConfig, discovery]);
|
|
283
257
|
return startAuth;
|
|
284
258
|
};
|
|
285
|
-
const useDestroy = (
|
|
259
|
+
const useDestroy = (storageKey, refreshTokenRef, expirationDateRef, setToken, setAuthState) => {
|
|
286
260
|
return useCallback(async () => {
|
|
287
|
-
await deleteTokenStorage(
|
|
261
|
+
await deleteTokenStorage(storageKey);
|
|
288
262
|
setToken(null);
|
|
289
263
|
refreshTokenRef.current = null;
|
|
290
264
|
expirationDateRef.current = null;
|
|
291
265
|
setAuthState('unauthorized');
|
|
292
|
-
}, [
|
|
266
|
+
}, [storageKey, setAuthState]);
|
|
293
267
|
};
|
|
294
268
|
const useGetTokenAsync = (tokenRef, expirationDateRef, remainingTimeToRunRefresh, refresh) => {
|
|
295
269
|
return useCallback(async () => {
|
|
@@ -302,7 +276,7 @@ const useGetTokenAsync = (tokenRef, expirationDateRef, remainingTimeToRunRefresh
|
|
|
302
276
|
return tokenRef.current;
|
|
303
277
|
}, [refresh]);
|
|
304
278
|
};
|
|
305
|
-
export const IMOAuth = ({ children, requestConfig, remainingTimeToRunRefresh,
|
|
279
|
+
export const IMOAuth = ({ children, requestConfig, remainingTimeToRunRefresh, storageKey, oauthContext, }) => {
|
|
306
280
|
const Context = oauthContext || DefaultContext;
|
|
307
281
|
const contextRef = useRef();
|
|
308
282
|
const authStateRenderTarget = useRenderTarget();
|
|
@@ -311,14 +285,13 @@ export const IMOAuth = ({ children, requestConfig, remainingTimeToRunRefresh, se
|
|
|
311
285
|
const [tokenRef, setToken, getToken] = useTokenRef(tokenRenderTarget);
|
|
312
286
|
const refreshTokenRef = useRef(null);
|
|
313
287
|
const expirationDateRef = useRef(null);
|
|
314
|
-
const
|
|
288
|
+
const _storageKey = useStorageKey(storageKey);
|
|
315
289
|
const _remainingTimeToRunRefresh = useRemainingTimeToRunRefresh(remainingTimeToRunRefresh);
|
|
316
290
|
const _requestConfig = useRequestConfig(requestConfig);
|
|
317
291
|
const _discovery = useDiscovery();
|
|
318
|
-
const
|
|
319
|
-
const
|
|
320
|
-
const
|
|
321
|
-
const startAuth = useStartAuth(storeConfig, _remainingTimeToRunRefresh, refreshTokenRef, expirationDateRef, _requestConfig, _discovery, setToken, refresh, setAuthState, authErrorRenderTarget);
|
|
292
|
+
const destroy = useDestroy(_storageKey, refreshTokenRef, expirationDateRef, setToken, setAuthState);
|
|
293
|
+
const refresh = useRefresh(_storageKey, refreshTokenRef, expirationDateRef, _requestConfig, _discovery, setToken, destroy);
|
|
294
|
+
const startAuth = useStartAuth(_storageKey, _remainingTimeToRunRefresh, refreshTokenRef, expirationDateRef, _requestConfig, _discovery, setToken, refresh, setAuthState);
|
|
322
295
|
const getTokenAsync = useGetTokenAsync(tokenRef, expirationDateRef, _remainingTimeToRunRefresh, refresh);
|
|
323
296
|
contextRef.current = {
|
|
324
297
|
getAuthState,
|
|
@@ -329,7 +302,6 @@ export const IMOAuth = ({ children, requestConfig, remainingTimeToRunRefresh, se
|
|
|
329
302
|
startAuth,
|
|
330
303
|
tokenRenderTarget,
|
|
331
304
|
authStateRenderTarget,
|
|
332
|
-
authErrorRenderTarget,
|
|
333
305
|
};
|
|
334
306
|
return (<Context.Provider value={contextRef.current}>{children}</Context.Provider>);
|
|
335
307
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { Context as DefaultContext } from '../Context';
|
|
2
2
|
export declare const useIMSearch: (Context?: typeof DefaultContext) => {
|
|
3
|
-
startSearch: ({ target, type, paramString, }: import("..").StartSearchArg) => Promise<import("..").StartSearchResult<
|
|
3
|
+
startSearch: ({ target, type, paramString, }: import("..").StartSearchArg) => Promise<import("..").StartSearchResult<typeof type>>;
|
|
4
4
|
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
1
|
import { Context as DefaultContext } from './Context';
|
|
3
2
|
import { DepartmentPostSearchRecord, DepartmentSearchRecord, PostSearchRecord, PublicGroupSearchRecord, RoleSearchRecord, UserSearchRecord } from './types';
|
|
4
3
|
export type SearchTarget = 'jp.co.intra_mart.master.search.user' | 'jp.co.intra_mart.master.search.company' | 'jp.co.intra_mart.master.search.company_post' | 'jp.co.intra_mart.master.search.department' | 'jp.co.intra_mart.master.search.public_group' | 'jp.co.intra_mart.master.search.private_group' | 'jp.co.intra_mart.master.search.public_group_role' | 'jp.co.intra_mart.master.search.role' | 'jp.co.intra_mart.master.search.attached_department_post' | 'jp.co.intra_mart.master.search.attached_public_group_role' | undefined;
|
package/lib/utils/mergeRef.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const mergeRef: <T>(...refs: (string | import("react").MutableRefObject<T> | ((instance: T | null) => void) | import("react").MutableRefObject<T | null> | ((instance: T | null) => void) | import("react").RefObject<T> | null)[]) => (instance: T | null) => void;
|
|
1
|
+
export declare const mergeRef: <T>(...refs: Array<React.MutableRefObject<T> | React.ForwardedRef<T> | React.LegacyRef<T> | React.ForwardedRef<T>>) => React.RefCallback<T>;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intra-mart/smartlime",
|
|
3
3
|
"description": "expoで使用できるintra mart accelplatform SDK",
|
|
4
|
-
"version": "2.0.0-dev.
|
|
4
|
+
"version": "2.0.0-dev.20241210",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"intra-mart",
|
|
7
7
|
"AccelPlatform",
|
|
@@ -42,40 +42,40 @@
|
|
|
42
42
|
"type": "tsc --noEmit"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"expo": "^
|
|
46
|
-
"react": "18.
|
|
45
|
+
"expo": "^52.0.17",
|
|
46
|
+
"react": "18.3.1"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"@react-native-async-storage/async-storage": "1.23.1",
|
|
50
|
-
"expo-auth-session": "~
|
|
51
|
-
"expo-crypto": "~
|
|
50
|
+
"expo-auth-session": "~6.0.1",
|
|
51
|
+
"expo-crypto": "~14.0.1",
|
|
52
52
|
"expo-random": "~14.0.1",
|
|
53
|
-
"expo-secure-store": "~
|
|
54
|
-
"react-native-webview": "13.
|
|
55
|
-
"set-cookie-parser": "^2.7.
|
|
53
|
+
"expo-secure-store": "~14.0.0",
|
|
54
|
+
"react-native-webview": "13.12.5",
|
|
55
|
+
"set-cookie-parser": "^2.7.1"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
|
-
"@babel/core": "^7.
|
|
59
|
-
"@babel/preset-env": "^7.
|
|
60
|
-
"@types/jest": "^29.5.
|
|
58
|
+
"@babel/core": "^7.26.0",
|
|
59
|
+
"@babel/preset-env": "^7.26.0",
|
|
60
|
+
"@types/jest": "^29.5.14",
|
|
61
61
|
"@types/react": "^18.2.79",
|
|
62
62
|
"@types/react-test-renderer": "18.3.0",
|
|
63
63
|
"@types/set-cookie-parser": "^2.4.10",
|
|
64
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
65
|
-
"@typescript-eslint/parser": "^8.
|
|
66
|
-
"eslint": "^
|
|
64
|
+
"@typescript-eslint/eslint-plugin": "^8.18.0",
|
|
65
|
+
"@typescript-eslint/parser": "^8.18.0",
|
|
66
|
+
"eslint": "^9.16.0",
|
|
67
67
|
"eslint-config-prettier": "^9.1.0",
|
|
68
|
-
"eslint-plugin-react": "^7.
|
|
69
|
-
"expo": "^
|
|
68
|
+
"eslint-plugin-react": "^7.37.2",
|
|
69
|
+
"expo": "^52.0.17",
|
|
70
70
|
"jest": "^29.7.0",
|
|
71
|
-
"jest-expo": "^
|
|
72
|
-
"prettier": "^3.
|
|
73
|
-
"react": "18.
|
|
74
|
-
"react-dom": "18.
|
|
75
|
-
"react-native": "0.
|
|
71
|
+
"jest-expo": "^52.0.2",
|
|
72
|
+
"prettier": "^3.4.2",
|
|
73
|
+
"react": "18.3.1",
|
|
74
|
+
"react-dom": "18.3.1",
|
|
75
|
+
"react-native": "0.76.3",
|
|
76
76
|
"react-test-renderer": "18.2.0",
|
|
77
77
|
"ts-jest": "^29.2.5",
|
|
78
|
-
"typescript": "^5.
|
|
78
|
+
"typescript": "^5.7.2"
|
|
79
79
|
},
|
|
80
80
|
"resolutions": {
|
|
81
81
|
"@types/react": "^18.2.79"
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { useContext, useEffect } from 'react';
|
|
2
|
-
import { Context as DefaultContext } from '../Context';
|
|
3
|
-
import { IMOAuthError } from '../IMOAuthError';
|
|
4
|
-
export const useAuthError = (callBack) => {
|
|
5
|
-
const oauthContext = useContext(DefaultContext);
|
|
6
|
-
if (oauthContext == null) {
|
|
7
|
-
throw new IMOAuthError('useAuthError requires either a Context provide or an ancestor element with a IMOAuthProvider.');
|
|
8
|
-
}
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
oauthContext.authErrorRenderTarget.addEventListener(callBack);
|
|
11
|
-
return () => {
|
|
12
|
-
oauthContext.authErrorRenderTarget.removeEventListener(callBack);
|
|
13
|
-
};
|
|
14
|
-
}, [callBack]);
|
|
15
|
-
};
|