@intra-mart/smartlime 0.0.1-beta → 1.0.0-dev.20230228

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.
@@ -19,6 +19,7 @@ export type StartAuthResult = {
19
19
  };
20
20
  export declare const IMPrompt: {
21
21
  readonly Login: Prompt.Login;
22
+ readonly None: Prompt.None;
22
23
  };
23
24
  interface RequestConfig {
24
25
  redirectUri: string;
@@ -26,7 +27,7 @@ interface RequestConfig {
26
27
  clientSecret: string;
27
28
  scopes: string[];
28
29
  state?: string;
29
- prompt?: Prompt.Login;
30
+ prompt?: Prompt.Login | Prompt.None;
30
31
  }
31
32
  interface IMOAuthProps {
32
33
  children: JSX.Element;
@@ -12,6 +12,7 @@ const DEFAULT_STORAGE_KEY = '@example:IMAuthKey';
12
12
  const DEFAULT_REMAINING_TIME_TO_RUN_REFRESH = 360000;
13
13
  export const IMPrompt = {
14
14
  Login: Prompt.Login,
15
+ None: Prompt.None,
15
16
  };
16
17
  const baseRequestConfig = {
17
18
  responseType: 'code',
@@ -22,6 +23,11 @@ const useRequestConfig = (userProps) => {
22
23
  return {
23
24
  ...baseRequestConfig,
24
25
  ...userProps,
26
+ /*
27
+ error can occur during authorization due to iap session control.
28
+ default to "login" which destroy the session every time to prevent error.
29
+ */
30
+ prompt: userProps.prompt ? userProps.prompt : IMPrompt.Login,
25
31
  extraParams: {
26
32
  redirect_uri: userProps.redirectUri,
27
33
  },
@@ -7,5 +7,6 @@ export interface IMWebViewProps extends Omit<WebViewProps, 'onShouldStartLoadWit
7
7
  source: WebViewSourceUri;
8
8
  onSessionCreationError?: OnSessionCreationError;
9
9
  indicator?: JSX.Element | null;
10
+ forceLogin?: boolean;
10
11
  }
11
12
  export declare const IMWebView: React.ForwardRefExoticComponent<IMWebViewProps & React.RefAttributes<WebView<{}>>>;
@@ -13,7 +13,7 @@ const useCheckSessionUrl = (baseUrl) => {
13
13
  const useGetSessionUrl = (baseUrl) => {
14
14
  return join(baseUrl, '/api/bearer/smacolow/session');
15
15
  };
16
- const usLogoutUrl = (baseUrl) => {
16
+ const useLogoutUrl = (baseUrl) => {
17
17
  return join(baseUrl, '/logout');
18
18
  };
19
19
  const useLogin = (props, webviewRef) => {
@@ -22,8 +22,9 @@ const useLogin = (props, webviewRef) => {
22
22
  const targetUrl = props.source.uri;
23
23
  const checkSessionUrl = useCheckSessionUrl(baseUrl);
24
24
  const getSessionUrl = useGetSessionUrl(baseUrl);
25
- const logoutUrl = usLogoutUrl(baseUrl);
26
- const currentUrlRef = useRef(checkSessionUrl);
25
+ const logoutUrl = useLogoutUrl(baseUrl);
26
+ const initialUrlRef = useRef(props.forceLogin ? logoutUrl : checkSessionUrl);
27
+ const currentUrlRef = useRef(initialUrlRef.current);
27
28
  const isCheckSessionErrorRef = useRef(false);
28
29
  const [isFailedLogin, setIsFailedLogin] = useState(false);
29
30
  const [isLogin, setIsLogin] = useState(false);
@@ -123,7 +124,7 @@ const useLogin = (props, webviewRef) => {
123
124
  };
124
125
  const autoLoginProps = {
125
126
  source: {
126
- uri: checkSessionUrl,
127
+ uri: initialUrlRef.current,
127
128
  },
128
129
  sharedCookiesEnabled: false,
129
130
  onLoad,
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": "0.0.1-beta",
4
+ "version": "1.0.0-dev.20230228",
5
5
  "keywords": [
6
6
  "intra-mart",
7
7
  "AccelPlatform",
package/.gitattributes DELETED
@@ -1 +0,0 @@
1
- * text=auto eol=crlf