@equinor/mad-auth 0.3.0 → 0.5.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.
Files changed (43) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/README.md +3 -24
  3. package/dist/Expo-AuthSession/authenticationHandler/auth.d.ts +2 -2
  4. package/dist/Expo-AuthSession/authenticationHandler/auth.js +4 -4
  5. package/dist/Expo-AuthSession/authenticationHandler/index.d.ts +1 -1
  6. package/dist/Expo-AuthSession/authenticationHandler/index.js +7 -7
  7. package/dist/Expo-AuthSession/authenticationHandler/web/authWeb.d.ts +3 -1
  8. package/dist/Expo-AuthSession/authenticationHandler/web/authWeb.js +5 -1
  9. package/dist/Expo-AuthSession/authenticationHandler/web/index.js +5 -1
  10. package/dist/Expo-AuthSession/components/LoginButton.js +9 -9
  11. package/dist/Expo-AuthSession/hooks/useAccount.js +8 -8
  12. package/dist/Expo-AuthSession/hooks/useAuthenticate.js +8 -8
  13. package/dist/Expo-AuthSession/index.js +26 -12
  14. package/dist/Expo-AuthSession/store/authStore.d.ts +9 -1
  15. package/dist/Expo-AuthSession/store/authStore.js +16 -2
  16. package/dist/Expo-AuthSession/store/encryption.js +1 -1
  17. package/dist/Expo-AuthSession/types.d.ts +9 -2
  18. package/dist/Expo-AuthSession/utils/tokenRefresh.d.ts +1 -1
  19. package/dist/Expo-AuthSession/utils/tokenRefresh.js +3 -3
  20. package/dist/{chunk-BZJJPLOA.js → chunk-26ZZDCTT.js} +49 -7
  21. package/dist/{chunk-X2FA4SVJ.js → chunk-43BP7XC5.js} +5 -2
  22. package/dist/{chunk-PGRO37AZ.js → chunk-4LFUQDQT.js} +1 -1
  23. package/dist/{chunk-FJEJBJRU.js → chunk-AF7VKFEK.js} +15 -6
  24. package/dist/{chunk-5RSIJ5AN.js → chunk-BDM3AW6G.js} +2 -2
  25. package/dist/{chunk-TSYWYSXA.js → chunk-I4RUMC2G.js} +21 -7
  26. package/dist/{chunk-T5YGX52R.js → chunk-NNTKGUTE.js} +2 -2
  27. package/dist/{chunk-BDLB5HOI.js → chunk-RM5XQ5CO.js} +60 -15
  28. package/dist/{chunk-UGY2AUZX.js → chunk-T2OGWASD.js} +8 -13
  29. package/dist/{chunk-LT4NDIEQ.js → chunk-VE7QFTAE.js} +58 -32
  30. package/dist/index.js +12 -12
  31. package/package.json +3 -2
  32. package/dist/auth.d.ts +0 -0
  33. package/dist/auth.js +0 -0
  34. package/dist/components/LoginButton.d.ts +0 -0
  35. package/dist/components/LoginButton.js +0 -0
  36. package/dist/components/index.d.ts +0 -0
  37. package/dist/components/index.js +0 -0
  38. package/dist/hooks/index.d.ts +0 -0
  39. package/dist/hooks/index.js +0 -0
  40. package/dist/hooks/useAccount.d.ts +0 -0
  41. package/dist/hooks/useAccount.js +0 -0
  42. package/dist/hooks/useAuthenticate.d.ts +0 -0
  43. package/dist/hooks/useAuthenticate.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @equinor/mad-auth
2
2
 
3
+ ## 0.5.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6264746: re-rendering and ok button issue fix
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [6264746]
12
+ - @equinor/mad-components@0.24.0
13
+
14
+ ## 0.4.0
15
+
16
+ ### Minor Changes
17
+
18
+ - 07f0174: Authentication package fix to accept scope after migration to expo auth session
19
+
3
20
  ## 0.3.0
4
21
 
5
22
  ### Minor Changes
package/README.md CHANGED
@@ -1,32 +1,11 @@
1
1
  # MAD AUTH
2
2
 
3
- A simple authentication package used by the mad-team. It uses MSAL under the hood, and requires you
4
- to set up an app registration in azure.
3
+ A simple authentication package used by the mad-team. It uses expo-auth-session and
4
+ @azure/msal-browser under the hood, and requires you to set up an app registration in azure.
5
5
 
6
6
  # Usage
7
7
 
8
- You have to install `react-native-msal` in your app in order to make this work. `react-native-msal`
9
- is an archived package no longer maintained, but we have created a fork which you can find
10
- [here](https://github.com/equinor/react-native-msal). Install the newest commit by putting this in
11
- your `package.json`:
12
-
13
- ```json
14
- {
15
- "dependencies": {
16
- "react-native-msal": "git+https://github.com/equinor/react-native-msal.git#COMMIT_HASH"
17
- }
18
- }
19
- ```
20
-
21
- PS: you might need `yarn` installed on your computer for it to work.
22
-
23
- After installing it, follow
24
- [this guide if you use expo](https://github.com/equinor/react-native-msal/blob/main/docs/expo_setup.md),
25
- or
26
- [this guide for iOS setup in a bare react native project](https://github.com/equinor/react-native-msal/blob/main/docs/ios_setup.md).
27
- Our fork of `react-native-msal` will not work for Android.
28
-
29
- Next, add our provided `LoginButton` to your application:
8
+ Add our provided `LoginButton` to your application:
30
9
 
31
10
  ```tsx
32
11
  export const LoginScreen = () => {
@@ -13,12 +13,12 @@ export declare function authenticationClientExists(): boolean;
13
13
  * user has it installed
14
14
  * @returns {MadAuthenticationResult | null} an object containing the access token and the account, or null
15
15
  */
16
- export declare const authenticateInteractively: () => Promise<MadAuthenticationResult | null>;
16
+ export declare const authenticateInteractively: (scopes?: string[]) => Promise<MadAuthenticationResult | null>;
17
17
  /**
18
18
  * Authenticate silently.
19
19
  * @returns {MadAuthenticationResult | null} an object containing the access token and the account, or null
20
20
  */
21
- export declare const authenticateSilently: () => Promise<MadAuthenticationResult | null>;
21
+ export declare const authenticateSilently: (scopes?: string[]) => Promise<MadAuthenticationResult | null>;
22
22
  export declare function getAccount(): MadAccount | null;
23
23
  /**
24
24
  * Sign out the account.
@@ -6,11 +6,11 @@ import {
6
6
  initiateAuthenticationClient,
7
7
  reset,
8
8
  signOut
9
- } from "../../chunk-BDLB5HOI.js";
9
+ } from "../../chunk-RM5XQ5CO.js";
10
10
  import "../../chunk-7NSJ6UAV.js";
11
- import "../../chunk-X2FA4SVJ.js";
12
- import "../../chunk-BZJJPLOA.js";
13
- import "../../chunk-FJEJBJRU.js";
11
+ import "../../chunk-43BP7XC5.js";
12
+ import "../../chunk-26ZZDCTT.js";
13
+ import "../../chunk-AF7VKFEK.js";
14
14
  import "../../chunk-CWMXXUWU.js";
15
15
  export {
16
16
  authenticateInteractively,
@@ -4,5 +4,5 @@ import { AuthRequestConfig, DiscoveryDocument } from "expo-auth-session";
4
4
  export declare const signOut: () => boolean | Promise<boolean>;
5
5
  export declare const authenticateSilently: (scopes?: string[]) => Promise<import("../..").MadAuthenticationResult | null>;
6
6
  export declare const authenticateInteractively: (scopes?: string[]) => Promise<import("../..").MadAuthenticationResult | null>;
7
- export declare const initiateAuthenticationClient: (config: AuthRequestConfig, discovery: DiscoveryDocument) => Promise<void>;
7
+ export declare const initiateAuthenticationClient: (config: AuthRequestConfig, discovery: DiscoveryDocument) => void;
8
8
  export declare const authenticationClientExists: () => boolean;
@@ -4,21 +4,21 @@ import {
4
4
  authenticationClientExists,
5
5
  initiateAuthenticationClient,
6
6
  signOut
7
- } from "../../chunk-UGY2AUZX.js";
7
+ } from "../../chunk-T2OGWASD.js";
8
8
  import "../../chunk-H623QQTI.js";
9
9
  import {
10
10
  getAccountWeb
11
- } from "../../chunk-LT4NDIEQ.js";
11
+ } from "../../chunk-VE7QFTAE.js";
12
12
  import "../../chunk-GRAW2VSL.js";
13
13
  import "../../chunk-MWXZHQN3.js";
14
+ import "../../chunk-7SOSXNKP.js";
14
15
  import {
15
16
  getAccount
16
- } from "../../chunk-BDLB5HOI.js";
17
+ } from "../../chunk-RM5XQ5CO.js";
17
18
  import "../../chunk-7NSJ6UAV.js";
18
- import "../../chunk-X2FA4SVJ.js";
19
- import "../../chunk-BZJJPLOA.js";
20
- import "../../chunk-FJEJBJRU.js";
21
- import "../../chunk-7SOSXNKP.js";
19
+ import "../../chunk-43BP7XC5.js";
20
+ import "../../chunk-26ZZDCTT.js";
21
+ import "../../chunk-AF7VKFEK.js";
22
22
  import "../../chunk-CWMXXUWU.js";
23
23
  export {
24
24
  authenticateInteractively,
@@ -1,3 +1,4 @@
1
+ import { PublicClientApplication } from "./publicClientApplication";
1
2
  import { MadAccount, MadAuthenticationResult } from "../../../types";
2
3
  export type InitiateAuthenticationClientConfig = {
3
4
  clientId: string;
@@ -8,7 +9,8 @@ export type InitiateAuthenticationClientConfig = {
8
9
  * Initiate the authentication client
9
10
  * @param {InitiateAuthenticationClientConfig} config
10
11
  */
11
- export declare function initiateAuthenticationClientWeb({ clientId, redirectUri, authority, }: InitiateAuthenticationClientConfig): Promise<void>;
12
+ export declare function initiateAuthenticationClientWeb({ clientId, redirectUri, authority, }: InitiateAuthenticationClientConfig): void;
13
+ export declare function ensurePcaInitialized(): Promise<PublicClientApplication> | null;
12
14
  /**
13
15
  * Check if the authentication client exists
14
16
  * @returns {boolean} whether the authentication client exists
@@ -3,19 +3,23 @@ import {
3
3
  authenticateInteractivelyWeb,
4
4
  authenticateSilentlyWeb,
5
5
  authenticationClientExistsWeb,
6
+ ensurePcaInitialized,
6
7
  getAccountWeb,
7
8
  initiateAuthenticationClientWeb,
8
9
  signOutWeb
9
- } from "../../../chunk-LT4NDIEQ.js";
10
+ } from "../../../chunk-VE7QFTAE.js";
10
11
  import "../../../chunk-GRAW2VSL.js";
11
12
  import "../../../chunk-MWXZHQN3.js";
12
13
  import "../../../chunk-7SOSXNKP.js";
14
+ import "../../../chunk-26ZZDCTT.js";
15
+ import "../../../chunk-AF7VKFEK.js";
13
16
  import "../../../chunk-CWMXXUWU.js";
14
17
  export {
15
18
  _resetWeb,
16
19
  authenticateInteractivelyWeb,
17
20
  authenticateSilentlyWeb,
18
21
  authenticationClientExistsWeb,
22
+ ensurePcaInitialized,
19
23
  getAccountWeb,
20
24
  initiateAuthenticationClientWeb,
21
25
  signOutWeb
@@ -6,10 +6,11 @@ import {
6
6
  authenticateInteractivelyWeb,
7
7
  authenticateSilentlyWeb,
8
8
  authenticationClientExistsWeb,
9
+ ensurePcaInitialized,
9
10
  getAccountWeb,
10
11
  initiateAuthenticationClientWeb,
11
12
  signOutWeb
12
- } from "../../../chunk-LT4NDIEQ.js";
13
+ } from "../../../chunk-VE7QFTAE.js";
13
14
  import "../../../chunk-GRAW2VSL.js";
14
15
  import {
15
16
  Ios_MSALWebviewType,
@@ -17,6 +18,8 @@ import {
17
18
  MSALPromptType
18
19
  } from "../../../chunk-MWXZHQN3.js";
19
20
  import "../../../chunk-7SOSXNKP.js";
21
+ import "../../../chunk-26ZZDCTT.js";
22
+ import "../../../chunk-AF7VKFEK.js";
20
23
  import "../../../chunk-CWMXXUWU.js";
21
24
  export {
22
25
  Ios_MSALWebviewType,
@@ -27,6 +30,7 @@ export {
27
30
  authenticateSilentlyWeb,
28
31
  authenticationClientExistsWeb,
29
32
  web_default as default,
33
+ ensurePcaInitialized,
30
34
  getAccountWeb,
31
35
  initiateAuthenticationClientWeb,
32
36
  signOutWeb
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  LoginButton
3
- } from "../../chunk-PGRO37AZ.js";
4
- import "../../chunk-T5YGX52R.js";
5
- import "../../chunk-UGY2AUZX.js";
3
+ } from "../../chunk-4LFUQDQT.js";
4
+ import "../../chunk-NNTKGUTE.js";
5
+ import "../../chunk-T2OGWASD.js";
6
6
  import "../../chunk-H623QQTI.js";
7
- import "../../chunk-LT4NDIEQ.js";
7
+ import "../../chunk-VE7QFTAE.js";
8
8
  import "../../chunk-GRAW2VSL.js";
9
9
  import "../../chunk-MWXZHQN3.js";
10
- import "../../chunk-BDLB5HOI.js";
11
- import "../../chunk-7NSJ6UAV.js";
12
- import "../../chunk-X2FA4SVJ.js";
13
- import "../../chunk-BZJJPLOA.js";
14
- import "../../chunk-FJEJBJRU.js";
15
10
  import "../../chunk-7SOSXNKP.js";
11
+ import "../../chunk-RM5XQ5CO.js";
12
+ import "../../chunk-7NSJ6UAV.js";
13
+ import "../../chunk-43BP7XC5.js";
14
+ import "../../chunk-26ZZDCTT.js";
15
+ import "../../chunk-AF7VKFEK.js";
16
16
  import "../../chunk-CWMXXUWU.js";
17
17
  export {
18
18
  LoginButton
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  useAccount
3
- } from "../../chunk-5RSIJ5AN.js";
4
- import "../../chunk-UGY2AUZX.js";
3
+ } from "../../chunk-BDM3AW6G.js";
4
+ import "../../chunk-T2OGWASD.js";
5
5
  import "../../chunk-H623QQTI.js";
6
- import "../../chunk-LT4NDIEQ.js";
6
+ import "../../chunk-VE7QFTAE.js";
7
7
  import "../../chunk-GRAW2VSL.js";
8
8
  import "../../chunk-MWXZHQN3.js";
9
- import "../../chunk-BDLB5HOI.js";
10
- import "../../chunk-7NSJ6UAV.js";
11
- import "../../chunk-X2FA4SVJ.js";
12
- import "../../chunk-BZJJPLOA.js";
13
- import "../../chunk-FJEJBJRU.js";
14
9
  import "../../chunk-7SOSXNKP.js";
10
+ import "../../chunk-RM5XQ5CO.js";
11
+ import "../../chunk-7NSJ6UAV.js";
12
+ import "../../chunk-43BP7XC5.js";
13
+ import "../../chunk-26ZZDCTT.js";
14
+ import "../../chunk-AF7VKFEK.js";
15
15
  import "../../chunk-CWMXXUWU.js";
16
16
  export {
17
17
  useAccount
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  useAuthenticate
3
- } from "../../chunk-T5YGX52R.js";
4
- import "../../chunk-UGY2AUZX.js";
3
+ } from "../../chunk-NNTKGUTE.js";
4
+ import "../../chunk-T2OGWASD.js";
5
5
  import "../../chunk-H623QQTI.js";
6
- import "../../chunk-LT4NDIEQ.js";
6
+ import "../../chunk-VE7QFTAE.js";
7
7
  import "../../chunk-GRAW2VSL.js";
8
8
  import "../../chunk-MWXZHQN3.js";
9
- import "../../chunk-BDLB5HOI.js";
10
- import "../../chunk-7NSJ6UAV.js";
11
- import "../../chunk-X2FA4SVJ.js";
12
- import "../../chunk-BZJJPLOA.js";
13
- import "../../chunk-FJEJBJRU.js";
14
9
  import "../../chunk-7SOSXNKP.js";
10
+ import "../../chunk-RM5XQ5CO.js";
11
+ import "../../chunk-7NSJ6UAV.js";
12
+ import "../../chunk-43BP7XC5.js";
13
+ import "../../chunk-26ZZDCTT.js";
14
+ import "../../chunk-AF7VKFEK.js";
15
15
  import "../../chunk-CWMXXUWU.js";
16
16
  export {
17
17
  useAuthenticate
@@ -1,49 +1,56 @@
1
- import "../chunk-TSYWYSXA.js";
1
+ import "../chunk-I4RUMC2G.js";
2
2
  import {
3
3
  useAccount
4
- } from "../chunk-5RSIJ5AN.js";
4
+ } from "../chunk-BDM3AW6G.js";
5
+ import "../chunk-NP4GJ5X5.js";
5
6
  import {
6
7
  LoginButton
7
- } from "../chunk-PGRO37AZ.js";
8
+ } from "../chunk-4LFUQDQT.js";
8
9
  import {
9
10
  useAuthenticate
10
- } from "../chunk-T5YGX52R.js";
11
+ } from "../chunk-NNTKGUTE.js";
11
12
  import {
12
13
  authenticateInteractively,
13
14
  authenticateSilently,
14
15
  authenticationClientExists,
15
16
  initiateAuthenticationClient,
16
17
  signOut
17
- } from "../chunk-UGY2AUZX.js";
18
+ } from "../chunk-T2OGWASD.js";
18
19
  import "../chunk-H623QQTI.js";
19
20
  import {
20
21
  getAccountWeb
21
- } from "../chunk-LT4NDIEQ.js";
22
+ } from "../chunk-VE7QFTAE.js";
22
23
  import "../chunk-GRAW2VSL.js";
23
24
  import "../chunk-MWXZHQN3.js";
25
+ import "../chunk-7SOSXNKP.js";
24
26
  import {
25
27
  getAccount
26
- } from "../chunk-BDLB5HOI.js";
28
+ } from "../chunk-RM5XQ5CO.js";
27
29
  import "../chunk-7NSJ6UAV.js";
28
- import "../chunk-X2FA4SVJ.js";
30
+ import "../chunk-43BP7XC5.js";
29
31
  import {
32
+ getAllTokens,
30
33
  getConfig,
31
34
  getDiscovery,
35
+ getRefreshToken,
32
36
  getToken,
33
37
  getUserData,
38
+ getWebConfig,
34
39
  resetConfig,
35
40
  resetDiscovery,
41
+ resetRefreshToken,
36
42
  resetToken,
37
43
  resetUserData,
44
+ resetWebConfig,
38
45
  setConfig,
39
46
  setDiscovery,
47
+ setRefreshToken,
40
48
  setToken,
41
49
  setUserData,
50
+ setWebConfig,
42
51
  useAuth
43
- } from "../chunk-BZJJPLOA.js";
44
- import "../chunk-FJEJBJRU.js";
45
- import "../chunk-NP4GJ5X5.js";
46
- import "../chunk-7SOSXNKP.js";
52
+ } from "../chunk-26ZZDCTT.js";
53
+ import "../chunk-AF7VKFEK.js";
47
54
  import "../chunk-CWMXXUWU.js";
48
55
  export {
49
56
  LoginButton,
@@ -52,19 +59,26 @@ export {
52
59
  authenticationClientExists,
53
60
  getAccount,
54
61
  getAccountWeb,
62
+ getAllTokens,
55
63
  getConfig,
56
64
  getDiscovery,
65
+ getRefreshToken,
57
66
  getToken,
58
67
  getUserData,
68
+ getWebConfig,
59
69
  initiateAuthenticationClient,
60
70
  resetConfig,
61
71
  resetDiscovery,
72
+ resetRefreshToken,
62
73
  resetToken,
63
74
  resetUserData,
75
+ resetWebConfig,
64
76
  setConfig,
65
77
  setDiscovery,
78
+ setRefreshToken,
66
79
  setToken,
67
80
  setUserData,
81
+ setWebConfig,
68
82
  signOut,
69
83
  useAccount,
70
84
  useAuth,
@@ -1,6 +1,7 @@
1
1
  import { AuthRequestConfig, DiscoveryDocument, TokenResponse } from "expo-auth-session";
2
2
  import { AuthState } from "../types";
3
3
  import { MadAccount } from "../../types";
4
+ import { InitiateAuthenticationClientConfig } from "../authenticationHandler/web";
4
5
  /**
5
6
  * Creates a zustand store with all the relevant values for authentication handling. Token and user info is persisted
6
7
  */
@@ -22,15 +23,22 @@ export declare const useAuth: import("zustand").UseBoundStore<Omit<Omit<import("
22
23
  /**
23
24
  * We avoid using hooks for backwards compatibility so these are all methods to interact with the store without the use of hooks.
24
25
  */
25
- export declare const getToken: () => TokenResponse | undefined;
26
+ export declare const getToken: (scopes?: string[]) => TokenResponse | null | undefined;
27
+ export declare const getAllTokens: () => TokenResponse[] | undefined;
26
28
  export declare const getUserData: () => MadAccount | undefined;
27
29
  export declare const getDiscovery: () => DiscoveryDocument | null | undefined;
28
30
  export declare const getConfig: () => AuthRequestConfig | undefined;
31
+ export declare const getWebConfig: () => InitiateAuthenticationClientConfig | undefined;
32
+ export declare const getRefreshToken: () => string | undefined;
29
33
  export declare const setToken: (token: TokenResponse) => void;
30
34
  export declare const setUserData: (userData: MadAccount) => void;
31
35
  export declare const setDiscovery: (discovery: DiscoveryDocument) => void;
32
36
  export declare const setConfig: (config: AuthRequestConfig) => void;
37
+ export declare const setWebConfig: (webConfig: InitiateAuthenticationClientConfig) => void;
38
+ export declare const setRefreshToken: (refreshToken: string) => void;
33
39
  export declare const resetToken: () => void;
34
40
  export declare const resetUserData: () => void;
35
41
  export declare const resetDiscovery: () => void;
36
42
  export declare const resetConfig: () => void;
43
+ export declare const resetWebConfig: () => void;
44
+ export declare const resetRefreshToken: () => void;
@@ -1,32 +1,46 @@
1
1
  import {
2
+ getAllTokens,
2
3
  getConfig,
3
4
  getDiscovery,
5
+ getRefreshToken,
4
6
  getToken,
5
7
  getUserData,
8
+ getWebConfig,
6
9
  resetConfig,
7
10
  resetDiscovery,
11
+ resetRefreshToken,
8
12
  resetToken,
9
13
  resetUserData,
14
+ resetWebConfig,
10
15
  setConfig,
11
16
  setDiscovery,
17
+ setRefreshToken,
12
18
  setToken,
13
19
  setUserData,
20
+ setWebConfig,
14
21
  useAuth
15
- } from "../../chunk-BZJJPLOA.js";
16
- import "../../chunk-FJEJBJRU.js";
22
+ } from "../../chunk-26ZZDCTT.js";
23
+ import "../../chunk-AF7VKFEK.js";
17
24
  import "../../chunk-CWMXXUWU.js";
18
25
  export {
26
+ getAllTokens,
19
27
  getConfig,
20
28
  getDiscovery,
29
+ getRefreshToken,
21
30
  getToken,
22
31
  getUserData,
32
+ getWebConfig,
23
33
  resetConfig,
24
34
  resetDiscovery,
35
+ resetRefreshToken,
25
36
  resetToken,
26
37
  resetUserData,
38
+ resetWebConfig,
27
39
  setConfig,
28
40
  setDiscovery,
41
+ setRefreshToken,
29
42
  setToken,
30
43
  setUserData,
44
+ setWebConfig,
31
45
  useAuth
32
46
  };
@@ -2,7 +2,7 @@ import {
2
2
  getItem,
3
3
  removeItem,
4
4
  setItem
5
- } from "../../chunk-FJEJBJRU.js";
5
+ } from "../../chunk-AF7VKFEK.js";
6
6
  import "../../chunk-CWMXXUWU.js";
7
7
  export {
8
8
  getItem,
@@ -1,7 +1,8 @@
1
- import { AuthRequestConfig, DiscoveryDocument, TokenResponse, TokenResponseConfig } from "expo-auth-session";
1
+ import { AuthRequestConfig, DiscoveryDocument, TokenResponse } from "expo-auth-session";
2
2
  import { MadAccount } from "../types";
3
+ import { InitiateAuthenticationClientConfig } from "./authenticationHandler/web";
3
4
  export type AuthState = {
4
- token?: TokenResponseConfig;
5
+ token?: TokenResponse[];
5
6
  setToken: (token: TokenResponse) => void;
6
7
  resetToken: () => void;
7
8
  userData?: MadAccount;
@@ -13,4 +14,10 @@ export type AuthState = {
13
14
  config?: AuthRequestConfig;
14
15
  setConfig: (config: AuthRequestConfig) => void;
15
16
  resetConfig: () => void;
17
+ refreshToken?: string;
18
+ setRefreshToken: (refreshToken: string) => void;
19
+ resetRefreshToken: () => void;
20
+ webConfig?: InitiateAuthenticationClientConfig;
21
+ setWebConfig: (webConfig: InitiateAuthenticationClientConfig) => void;
22
+ resetWebConfig: () => void;
16
23
  };
@@ -1,2 +1,2 @@
1
1
  import { TokenResponse } from "expo-auth-session";
2
- export declare const tokenRefresh: (token: TokenResponse) => Promise<TokenResponse | undefined>;
2
+ export declare const tokenRefresh: (token: TokenResponse, scopes?: string[]) => Promise<TokenResponse | undefined>;
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  tokenRefresh
3
- } from "../../chunk-X2FA4SVJ.js";
4
- import "../../chunk-BZJJPLOA.js";
5
- import "../../chunk-FJEJBJRU.js";
3
+ } from "../../chunk-43BP7XC5.js";
4
+ import "../../chunk-26ZZDCTT.js";
5
+ import "../../chunk-AF7VKFEK.js";
6
6
  import "../../chunk-CWMXXUWU.js";
7
7
  export {
8
8
  tokenRefresh
@@ -2,7 +2,7 @@ import {
2
2
  getItem,
3
3
  removeItem,
4
4
  setItem
5
- } from "./chunk-FJEJBJRU.js";
5
+ } from "./chunk-AF7VKFEK.js";
6
6
 
7
7
  // src/Expo-AuthSession/store/authStore.ts
8
8
  import { TokenResponse } from "expo-auth-session";
@@ -13,7 +13,13 @@ var useAuth = create()(
13
13
  persist(
14
14
  (set) => ({
15
15
  setToken: (token) => {
16
- set({ token });
16
+ set((state) => {
17
+ const filteredTokens = Array.isArray(state.token) ? state.token.filter((t) => t.scope !== token.scope) : [];
18
+ return { token: filteredTokens ? [...filteredTokens, token] : [token] };
19
+ });
20
+ },
21
+ setRefreshToken: (refreshToken) => {
22
+ set({ refreshToken });
17
23
  },
18
24
  setUserData: (account) => {
19
25
  set({ userData: account });
@@ -24,6 +30,9 @@ var useAuth = create()(
24
30
  setConfig: (config) => {
25
31
  set({ config });
26
32
  },
33
+ setWebConfig: (webConfig) => {
34
+ set({ webConfig });
35
+ },
27
36
  resetToken: () => {
28
37
  set({ token: void 0 });
29
38
  },
@@ -35,12 +44,18 @@ var useAuth = create()(
35
44
  },
36
45
  resetConfig: () => {
37
46
  set({ config: void 0 });
47
+ },
48
+ resetRefreshToken: () => {
49
+ set({ refreshToken: void 0 });
50
+ },
51
+ resetWebConfig: () => {
52
+ set({ webConfig: void 0 });
38
53
  }
39
54
  }),
40
55
  {
41
56
  partialize: (state) => Object.fromEntries(
42
57
  Object.entries(state).filter(
43
- ([key]) => ["token", "userData"].includes(key)
58
+ ([key]) => ["token", "userData", "webConfig", "refreshToken"].includes(key)
44
59
  )
45
60
  ),
46
61
  name: "storage",
@@ -54,34 +69,61 @@ var useAuth = create()(
54
69
  { name: "core/auth" }
55
70
  )
56
71
  );
57
- var getToken = () => {
58
- const tokenConfig = useAuth.getState().token;
59
- return tokenConfig ? new TokenResponse(tokenConfig) : void 0;
72
+ var getToken = (scopes) => {
73
+ const tokens = useAuth.getState().token;
74
+ const config = getConfig();
75
+ if (!scopes && !config) {
76
+ return tokens && tokens.length > 0 ? tokens[0] : null;
77
+ }
78
+ const currentScopes = scopes ? scopes : (config == null ? void 0 : config.scopes) ? config.scopes : [];
79
+ const omittedScopes = ["openid", "profile", "offline_access"];
80
+ const tokenWithScope = tokens ? tokens.find((t) => {
81
+ if (!t.scope) return false;
82
+ const granted = t.scope.split(" ");
83
+ return currentScopes.every(
84
+ (s) => omittedScopes.includes(s) || granted.includes(s)
85
+ );
86
+ }) : null;
87
+ return tokenWithScope ? new TokenResponse(tokenWithScope) : void 0;
60
88
  };
89
+ var getAllTokens = () => useAuth.getState().token;
61
90
  var getUserData = () => useAuth.getState().userData;
62
91
  var getDiscovery = () => useAuth.getState().discovery;
63
92
  var getConfig = () => useAuth.getState().config;
93
+ var getWebConfig = () => useAuth.getState().webConfig;
94
+ var getRefreshToken = () => useAuth.getState().refreshToken;
64
95
  var setToken = (token) => useAuth.getState().setToken(token);
65
96
  var setUserData = (userData) => useAuth.getState().setUserData(userData);
66
97
  var setDiscovery = (discovery) => useAuth.getState().setDiscovery(discovery);
67
98
  var setConfig = (config) => useAuth.getState().setConfig(config);
99
+ var setWebConfig = (webConfig) => useAuth.getState().setWebConfig(webConfig);
100
+ var setRefreshToken = (refreshToken) => useAuth.getState().setRefreshToken(refreshToken);
68
101
  var resetToken = () => useAuth.getState().resetToken();
69
102
  var resetUserData = () => useAuth.getState().resetUserData();
70
103
  var resetDiscovery = () => useAuth.getState().resetDiscovery();
71
104
  var resetConfig = () => useAuth.getState().resetConfig();
105
+ var resetWebConfig = () => useAuth.getState().resetWebConfig();
106
+ var resetRefreshToken = () => useAuth.getState().resetRefreshToken();
72
107
 
73
108
  export {
74
109
  useAuth,
75
110
  getToken,
111
+ getAllTokens,
76
112
  getUserData,
77
113
  getDiscovery,
78
114
  getConfig,
115
+ getWebConfig,
116
+ getRefreshToken,
79
117
  setToken,
80
118
  setUserData,
81
119
  setDiscovery,
82
120
  setConfig,
121
+ setWebConfig,
122
+ setRefreshToken,
83
123
  resetToken,
84
124
  resetUserData,
85
125
  resetDiscovery,
86
- resetConfig
126
+ resetConfig,
127
+ resetWebConfig,
128
+ resetRefreshToken
87
129
  };
@@ -1,18 +1,21 @@
1
1
  import {
2
2
  getConfig,
3
3
  getDiscovery
4
- } from "./chunk-BZJJPLOA.js";
4
+ } from "./chunk-26ZZDCTT.js";
5
5
  import {
6
6
  __async
7
7
  } from "./chunk-CWMXXUWU.js";
8
8
 
9
9
  // src/Expo-AuthSession/utils/tokenRefresh.ts
10
- var tokenRefresh = (token) => __async(null, null, function* () {
10
+ var tokenRefresh = (token, scopes) => __async(null, null, function* () {
11
11
  const discovery = getDiscovery();
12
12
  const config = getConfig();
13
13
  if (!discovery || !config) {
14
14
  return;
15
15
  }
16
+ if (scopes) {
17
+ config.scopes = scopes;
18
+ }
16
19
  return yield token.refreshAsync(config, discovery);
17
20
  });
18
21
 
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  useAuthenticate
3
- } from "./chunk-T5YGX52R.js";
3
+ } from "./chunk-NNTKGUTE.js";
4
4
  import {
5
5
  __objRest,
6
6
  __spreadValues
@@ -7,6 +7,7 @@ import AsyncStorage from "@react-native-async-storage/async-storage";
7
7
  import * as SecureStore from "expo-secure-store";
8
8
  import * as aesjs from "aes-js";
9
9
  import "react-native-get-random-values";
10
+ import { Platform } from "react-native";
10
11
  var encrypt = (key, value) => __async(null, null, function* () {
11
12
  const encryptionKey = crypto.getRandomValues(new Uint8Array(256 / 8));
12
13
  const cipher = new aesjs.ModeOfOperation.ctr(encryptionKey, new aesjs.Counter(1));
@@ -27,19 +28,27 @@ var decrypt = (key, value) => __async(null, null, function* () {
27
28
  return aesjs.utils.utf8.fromBytes(decryptedBytes);
28
29
  });
29
30
  var getItem = (key) => __async(null, null, function* () {
30
- const encrypted = yield AsyncStorage.getItem(key);
31
- if (!encrypted) {
32
- return encrypted;
31
+ if (Platform.OS === "web") {
32
+ return yield AsyncStorage.getItem(key);
33
+ } else {
34
+ const encrypted = yield AsyncStorage.getItem(key);
35
+ if (!encrypted) {
36
+ return encrypted;
37
+ }
38
+ return yield decrypt(key, encrypted);
33
39
  }
34
- return yield decrypt(key, encrypted);
35
40
  });
36
41
  var removeItem = (key) => __async(null, null, function* () {
37
42
  yield AsyncStorage.removeItem(key);
38
43
  yield SecureStore.deleteItemAsync(key);
39
44
  });
40
45
  var setItem = (key, value) => __async(null, null, function* () {
41
- const encrypted = yield encrypt(key, value);
42
- yield AsyncStorage.setItem(key, encrypted);
46
+ if (Platform.OS === "web") {
47
+ yield AsyncStorage.setItem(key, value);
48
+ } else {
49
+ const encrypted = yield encrypt(key, value);
50
+ yield AsyncStorage.setItem(key, encrypted);
51
+ }
43
52
  });
44
53
 
45
54
  export {
@@ -1,9 +1,9 @@
1
1
  import {
2
2
  getAccountWeb
3
- } from "./chunk-LT4NDIEQ.js";
3
+ } from "./chunk-VE7QFTAE.js";
4
4
  import {
5
5
  useAuth
6
- } from "./chunk-BZJJPLOA.js";
6
+ } from "./chunk-26ZZDCTT.js";
7
7
  import {
8
8
  __async
9
9
  } from "./chunk-CWMXXUWU.js";
@@ -1,40 +1,47 @@
1
1
  import {
2
2
  useAccount
3
- } from "./chunk-5RSIJ5AN.js";
3
+ } from "./chunk-BDM3AW6G.js";
4
4
  import {
5
5
  LoginButton
6
- } from "./chunk-PGRO37AZ.js";
6
+ } from "./chunk-4LFUQDQT.js";
7
7
  import {
8
8
  useAuthenticate
9
- } from "./chunk-T5YGX52R.js";
9
+ } from "./chunk-NNTKGUTE.js";
10
10
  import {
11
11
  authenticateInteractively,
12
12
  authenticateSilently,
13
13
  authenticationClientExists,
14
14
  initiateAuthenticationClient,
15
15
  signOut
16
- } from "./chunk-UGY2AUZX.js";
16
+ } from "./chunk-T2OGWASD.js";
17
17
  import {
18
18
  getAccountWeb
19
- } from "./chunk-LT4NDIEQ.js";
19
+ } from "./chunk-VE7QFTAE.js";
20
20
  import {
21
21
  getAccount
22
- } from "./chunk-BDLB5HOI.js";
22
+ } from "./chunk-RM5XQ5CO.js";
23
23
  import {
24
+ getAllTokens,
24
25
  getConfig,
25
26
  getDiscovery,
27
+ getRefreshToken,
26
28
  getToken,
27
29
  getUserData,
30
+ getWebConfig,
28
31
  resetConfig,
29
32
  resetDiscovery,
33
+ resetRefreshToken,
30
34
  resetToken,
31
35
  resetUserData,
36
+ resetWebConfig,
32
37
  setConfig,
33
38
  setDiscovery,
39
+ setRefreshToken,
34
40
  setToken,
35
41
  setUserData,
42
+ setWebConfig,
36
43
  useAuth
37
- } from "./chunk-BZJJPLOA.js";
44
+ } from "./chunk-26ZZDCTT.js";
38
45
  import {
39
46
  __export
40
47
  } from "./chunk-CWMXXUWU.js";
@@ -48,19 +55,26 @@ __export(Expo_AuthSession_exports, {
48
55
  authenticationClientExists: () => authenticationClientExists,
49
56
  getAccount: () => getAccount,
50
57
  getAccountWeb: () => getAccountWeb,
58
+ getAllTokens: () => getAllTokens,
51
59
  getConfig: () => getConfig,
52
60
  getDiscovery: () => getDiscovery,
61
+ getRefreshToken: () => getRefreshToken,
53
62
  getToken: () => getToken,
54
63
  getUserData: () => getUserData,
64
+ getWebConfig: () => getWebConfig,
55
65
  initiateAuthenticationClient: () => initiateAuthenticationClient,
56
66
  resetConfig: () => resetConfig,
57
67
  resetDiscovery: () => resetDiscovery,
68
+ resetRefreshToken: () => resetRefreshToken,
58
69
  resetToken: () => resetToken,
59
70
  resetUserData: () => resetUserData,
71
+ resetWebConfig: () => resetWebConfig,
60
72
  setConfig: () => setConfig,
61
73
  setDiscovery: () => setDiscovery,
74
+ setRefreshToken: () => setRefreshToken,
62
75
  setToken: () => setToken,
63
76
  setUserData: () => setUserData,
77
+ setWebConfig: () => setWebConfig,
64
78
  signOut: () => signOut,
65
79
  useAccount: () => useAccount,
66
80
  useAuth: () => useAuth,
@@ -3,7 +3,7 @@ import {
3
3
  authenticateSilently,
4
4
  authenticationClientExists,
5
5
  initiateAuthenticationClient
6
- } from "./chunk-UGY2AUZX.js";
6
+ } from "./chunk-T2OGWASD.js";
7
7
  import {
8
8
  __async
9
9
  } from "./chunk-CWMXXUWU.js";
@@ -35,7 +35,7 @@ var useAuthenticate = ({
35
35
  });
36
36
  useEffect(() => {
37
37
  const initiateClientAndMaybeAuthenticateSilently = () => __async(null, null, function* () {
38
- yield initiateAuthenticationClient(config, discovery);
38
+ initiateAuthenticationClient(config, discovery);
39
39
  if (authenticationClientExists()) setAuthenticationClientInitialized(true);
40
40
  if (enableAutomaticAuthentication)
41
41
  yield withAuthenticationPromiseHandler(
@@ -3,10 +3,11 @@ import {
3
3
  } from "./chunk-7NSJ6UAV.js";
4
4
  import {
5
5
  tokenRefresh
6
- } from "./chunk-X2FA4SVJ.js";
6
+ } from "./chunk-43BP7XC5.js";
7
7
  import {
8
8
  getConfig,
9
9
  getDiscovery,
10
+ getRefreshToken,
10
11
  getToken,
11
12
  getUserData,
12
13
  resetConfig,
@@ -15,9 +16,11 @@ import {
15
16
  resetUserData,
16
17
  setConfig,
17
18
  setDiscovery,
19
+ setRefreshToken,
18
20
  setToken,
19
- setUserData
20
- } from "./chunk-BZJJPLOA.js";
21
+ setUserData,
22
+ useAuth
23
+ } from "./chunk-26ZZDCTT.js";
21
24
  import {
22
25
  __async
23
26
  } from "./chunk-CWMXXUWU.js";
@@ -26,6 +29,7 @@ import {
26
29
  import {
27
30
  AuthRequest,
28
31
  exchangeCodeAsync,
32
+ refreshAsync,
29
33
  TokenResponse
30
34
  } from "expo-auth-session";
31
35
  import "core-js/stable/atob";
@@ -36,10 +40,13 @@ function initiateAuthenticationClient(config, discovery) {
36
40
  function authenticationClientExists() {
37
41
  return !!getConfig() && !!getDiscovery();
38
42
  }
39
- var authenticateInteractively = () => __async(null, null, function* () {
43
+ var authenticateInteractively = (scopes) => __async(null, null, function* () {
40
44
  const discovery = getDiscovery();
41
45
  const config = getConfig();
42
46
  if (!discovery || !config) return null;
47
+ if (scopes) {
48
+ config.scopes = scopes;
49
+ }
43
50
  const authRequest = new AuthRequest(config);
44
51
  const codeResponse = yield authRequest.promptAsync(discovery);
45
52
  if ((codeResponse == null ? void 0 : codeResponse.type) === "success") {
@@ -54,23 +61,61 @@ var authenticateInteractively = () => __async(null, null, function* () {
54
61
  if (!userData) return null;
55
62
  setUserData(userData);
56
63
  setToken(tokenResponse);
64
+ if (tokenResponse.refreshToken) setRefreshToken(tokenResponse.refreshToken);
57
65
  return { account: userData, accessToken: tokenResponse.accessToken };
58
66
  }
59
67
  return null;
60
68
  });
61
- var authenticateSilently = () => __async(null, null, function* () {
69
+ var authenticateSilently = (scopes) => __async(null, null, function* () {
70
+ yield useAuth.persist.rehydrate();
62
71
  const userData = getUserData();
63
- const token = getToken();
64
- if (!userData || !token) return null;
65
- if (TokenResponse.isTokenFresh(token)) {
66
- return { account: userData, accessToken: token.accessToken };
67
- }
68
- const newToken = yield tokenRefresh(token);
69
- if (newToken) {
70
- setToken(newToken);
71
- return { account: userData, accessToken: newToken.accessToken };
72
+ const token = getToken(scopes);
73
+ if (!userData) return null;
74
+ if (token) {
75
+ if (TokenResponse.isTokenFresh(token)) {
76
+ return {
77
+ account: userData,
78
+ accessToken: token.accessToken
79
+ };
80
+ }
81
+ const newToken = yield tokenRefresh(token, scopes);
82
+ if (newToken) {
83
+ setToken(newToken);
84
+ if (newToken.refreshToken) setRefreshToken(newToken.refreshToken);
85
+ return {
86
+ account: userData,
87
+ accessToken: newToken.accessToken
88
+ };
89
+ }
90
+ const interactiveToken = yield authenticateInteractively();
91
+ return interactiveToken;
92
+ } else {
93
+ const refreshToken = getRefreshToken();
94
+ const config = getConfig();
95
+ const discovery = getDiscovery();
96
+ if (!config || !discovery) return null;
97
+ if (refreshToken) {
98
+ try {
99
+ const refreshed = yield refreshAsync(
100
+ {
101
+ clientId: config.clientId,
102
+ refreshToken,
103
+ scopes
104
+ },
105
+ discovery
106
+ );
107
+ setToken(refreshed);
108
+ if (refreshed.refreshToken) setRefreshToken(refreshed.refreshToken);
109
+ return {
110
+ account: userData,
111
+ accessToken: refreshed.accessToken
112
+ };
113
+ } catch (e) {
114
+ return null;
115
+ }
116
+ }
117
+ return null;
72
118
  }
73
- return null;
74
119
  });
75
120
  function getAccount() {
76
121
  var _a;
@@ -4,29 +4,24 @@ import {
4
4
  authenticationClientExistsWeb,
5
5
  initiateAuthenticationClientWeb,
6
6
  signOutWeb
7
- } from "./chunk-LT4NDIEQ.js";
7
+ } from "./chunk-VE7QFTAE.js";
8
8
  import {
9
9
  authenticateInteractively,
10
10
  authenticateSilently,
11
11
  authenticationClientExists,
12
12
  initiateAuthenticationClient,
13
13
  signOut
14
- } from "./chunk-BDLB5HOI.js";
15
- import {
16
- __async
17
- } from "./chunk-CWMXXUWU.js";
14
+ } from "./chunk-RM5XQ5CO.js";
18
15
 
19
16
  // src/Expo-AuthSession/authenticationHandler/index.ts
20
17
  import { Platform } from "react-native";
21
18
  var signOut2 = () => Platform.OS === "web" ? signOutWeb() : signOut();
22
- var authenticateSilently2 = (scopes) => Platform.OS === "web" ? authenticateSilentlyWeb(scopes) : authenticateSilently();
23
- var authenticateInteractively2 = (scopes) => Platform.OS === "web" ? authenticateInteractivelyWeb(scopes) : authenticateInteractively();
24
- var initiateAuthenticationClient2 = (config, discovery) => __async(null, null, function* () {
25
- return Platform.OS === "web" ? yield initiateAuthenticationClientWeb({
26
- clientId: config.clientId,
27
- redirectUri: config.redirectUri
28
- }) : initiateAuthenticationClient(config, discovery);
29
- });
19
+ var authenticateSilently2 = (scopes) => Platform.OS === "web" ? authenticateSilentlyWeb(scopes) : authenticateSilently(scopes);
20
+ var authenticateInteractively2 = (scopes) => Platform.OS === "web" ? authenticateInteractivelyWeb(scopes) : authenticateInteractively(scopes);
21
+ var initiateAuthenticationClient2 = (config, discovery) => Platform.OS === "web" ? initiateAuthenticationClientWeb({
22
+ clientId: config.clientId,
23
+ redirectUri: config.redirectUri
24
+ }) : initiateAuthenticationClient(config, discovery);
30
25
  var authenticationClientExists2 = () => Platform.OS === "web" ? authenticationClientExistsWeb() : authenticationClientExists();
31
26
 
32
27
  export {
@@ -5,12 +5,18 @@ import {
5
5
  getMadAccount,
6
6
  getMadAuthenticationResult
7
7
  } from "./chunk-7SOSXNKP.js";
8
+ import {
9
+ getWebConfig,
10
+ setWebConfig,
11
+ useAuth
12
+ } from "./chunk-26ZZDCTT.js";
8
13
  import {
9
14
  __async
10
15
  } from "./chunk-CWMXXUWU.js";
11
16
 
12
17
  // src/Expo-AuthSession/authenticationHandler/web/authWeb.ts
13
18
  var pca = null;
19
+ var initPca = null;
14
20
  function _getMsalAccount() {
15
21
  return __async(this, null, function* () {
16
22
  if (!pca) {
@@ -30,24 +36,31 @@ function _getMadAccountFromMSAL() {
30
36
  return null;
31
37
  });
32
38
  }
33
- function initiateAuthenticationClientWeb(_0) {
34
- return __async(this, arguments, function* ({
35
- clientId,
36
- redirectUri,
37
- authority = "https://login.microsoftonline.com/statoilsrm.onmicrosoft.com/"
38
- }) {
39
- if (authenticationClientExistsWeb()) return;
40
- const config = {
41
- auth: {
42
- authority,
43
- clientId,
44
- redirectUri
45
- },
46
- cache: { cacheLocation: "localStorage" }
47
- };
48
- pca = new PublicClientApplication(config);
49
- yield pca.init();
50
- });
39
+ function initiateAuthenticationClientWeb({
40
+ clientId,
41
+ redirectUri,
42
+ authority = "https://login.microsoftonline.com/statoilsrm.onmicrosoft.com/"
43
+ }) {
44
+ if (authenticationClientExistsWeb()) return;
45
+ const config = {
46
+ auth: {
47
+ authority,
48
+ clientId,
49
+ redirectUri
50
+ },
51
+ cache: { cacheLocation: "localStorage" }
52
+ };
53
+ pca = new PublicClientApplication(config);
54
+ setWebConfig({ clientId, redirectUri, authority });
55
+ }
56
+ function ensurePcaInitialized() {
57
+ if (!pca) {
58
+ throw new Error("Unable to authenticate, authentication client does not exist");
59
+ }
60
+ if (!initPca) {
61
+ initPca = pca.init();
62
+ }
63
+ return initPca;
51
64
  }
52
65
  function authenticationClientExistsWeb() {
53
66
  return !!pca;
@@ -60,6 +73,7 @@ function authenticateInteractivelyWeb(scopes) {
60
73
  if (!scopes) {
61
74
  throw new Error("Unable to authenticate, scopes are not defined");
62
75
  }
76
+ yield ensurePcaInitialized();
63
77
  const result = yield pca.acquireToken({
64
78
  scopes
65
79
  });
@@ -74,23 +88,34 @@ function getAccountWeb() {
74
88
  }
75
89
  function authenticateSilentlyWeb(scopes) {
76
90
  return __async(this, null, function* () {
91
+ yield useAuth.persist.rehydrate();
92
+ const webConfig = getWebConfig();
77
93
  if (!pca) {
78
- throw new Error("Unable to authenticate, authentication client does not exist");
94
+ if (webConfig) {
95
+ initiateAuthenticationClientWeb(webConfig);
96
+ } else {
97
+ throw new Error("Unable to authenticate, authentication client does not exist");
98
+ }
79
99
  }
80
- const msalAccount = yield _getMsalAccount();
81
- if (msalAccount && scopes) {
82
- const params = {
83
- account: msalAccount,
84
- scopes,
85
- forceRefresh: false
86
- };
87
- const result = yield pca.acquireTokenSilent(params).catch((e) => {
88
- console.log("Error while fetching token silently", e);
89
- }).then((res) => res);
90
- if (!result) return null;
91
- return getMadAuthenticationResult(result);
100
+ if (pca) {
101
+ yield ensurePcaInitialized();
102
+ const msalAccount = yield _getMsalAccount();
103
+ if (msalAccount && scopes) {
104
+ const params = {
105
+ account: msalAccount,
106
+ scopes,
107
+ forceRefresh: false
108
+ };
109
+ const result = yield pca.acquireTokenSilent(params).catch((e) => {
110
+ console.log("Error while fetching token silently", e);
111
+ }).then((res) => res);
112
+ if (!result) return null;
113
+ return getMadAuthenticationResult(result);
114
+ }
115
+ throw new Error("Unable to authenticate, authentication client does not exist");
116
+ } else {
117
+ throw new Error("Unable to authenticate, authentication client does not exist");
92
118
  }
93
- return null;
94
119
  });
95
120
  }
96
121
  function signOutWeb() {
@@ -112,6 +137,7 @@ function _resetWeb() {
112
137
 
113
138
  export {
114
139
  initiateAuthenticationClientWeb,
140
+ ensurePcaInitialized,
115
141
  authenticationClientExistsWeb,
116
142
  authenticateInteractivelyWeb,
117
143
  getAccountWeb,
package/dist/index.js CHANGED
@@ -1,22 +1,22 @@
1
1
  import "./chunk-6F4PWJZI.js";
2
2
  import {
3
3
  Expo_AuthSession_exports
4
- } from "./chunk-TSYWYSXA.js";
5
- import "./chunk-5RSIJ5AN.js";
6
- import "./chunk-PGRO37AZ.js";
7
- import "./chunk-T5YGX52R.js";
8
- import "./chunk-UGY2AUZX.js";
4
+ } from "./chunk-I4RUMC2G.js";
5
+ import "./chunk-BDM3AW6G.js";
6
+ import "./chunk-NP4GJ5X5.js";
7
+ import "./chunk-4LFUQDQT.js";
8
+ import "./chunk-NNTKGUTE.js";
9
+ import "./chunk-T2OGWASD.js";
9
10
  import "./chunk-H623QQTI.js";
10
- import "./chunk-LT4NDIEQ.js";
11
+ import "./chunk-VE7QFTAE.js";
11
12
  import "./chunk-GRAW2VSL.js";
12
13
  import "./chunk-MWXZHQN3.js";
13
- import "./chunk-BDLB5HOI.js";
14
- import "./chunk-7NSJ6UAV.js";
15
- import "./chunk-X2FA4SVJ.js";
16
- import "./chunk-BZJJPLOA.js";
17
- import "./chunk-FJEJBJRU.js";
18
- import "./chunk-NP4GJ5X5.js";
19
14
  import "./chunk-7SOSXNKP.js";
15
+ import "./chunk-RM5XQ5CO.js";
16
+ import "./chunk-7NSJ6UAV.js";
17
+ import "./chunk-43BP7XC5.js";
18
+ import "./chunk-26ZZDCTT.js";
19
+ import "./chunk-AF7VKFEK.js";
20
20
  import "./chunk-CWMXXUWU.js";
21
21
  export {
22
22
  Expo_AuthSession_exports as ExpoAuthSession
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@equinor/mad-auth",
3
- "description": "A simple wrapper library for react-native-msal",
4
- "version": "0.3.0",
3
+ "description": "An authentication library that uses expo-auth-session (mobile) and @azure/msal-browser (web) under the hood",
4
+ "version": "0.5.0",
5
5
  "author": {
6
6
  "name": "Equinor Mobile App Delivery team (MAD)"
7
7
  },
@@ -47,6 +47,7 @@
47
47
  "license": "MIT",
48
48
  "main": "./dist/index.js",
49
49
  "peerDependencies": {
50
+ "@azure/msal-browser": "3.30.0",
50
51
  "expo-auth-session": "~6.0.0",
51
52
  "expo-crypto": "~14.0.1",
52
53
  "react": "19.0.0",
package/dist/auth.d.ts DELETED
File without changes
package/dist/auth.js DELETED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes