@equinor/mad-auth 0.2.17 → 0.4.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 (55) 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.js +9 -9
  6. package/dist/Expo-AuthSession/authenticationHandler/web/authWeb.d.ts +2 -0
  7. package/dist/Expo-AuthSession/authenticationHandler/web/authWeb.js +6 -2
  8. package/dist/Expo-AuthSession/authenticationHandler/web/index.js +7 -3
  9. package/dist/Expo-AuthSession/authenticationHandler/web/publicClientApplication.d.ts +1 -1
  10. package/dist/Expo-AuthSession/authenticationHandler/web/publicClientApplication.js +1 -1
  11. package/dist/Expo-AuthSession/components/LoginButton.d.ts +12 -1
  12. package/dist/Expo-AuthSession/components/LoginButton.js +11 -11
  13. package/dist/Expo-AuthSession/hooks/useAccount.js +10 -10
  14. package/dist/Expo-AuthSession/hooks/useAuthenticate.d.ts +1 -1
  15. package/dist/Expo-AuthSession/hooks/useAuthenticate.js +10 -10
  16. package/dist/Expo-AuthSession/index.js +28 -14
  17. package/dist/Expo-AuthSession/store/authStore.d.ts +10 -2
  18. package/dist/Expo-AuthSession/store/authStore.js +16 -2
  19. package/dist/Expo-AuthSession/store/encryption.js +1 -1
  20. package/dist/Expo-AuthSession/types.d.ts +9 -2
  21. package/dist/Expo-AuthSession/utils/tokenRefresh.d.ts +1 -1
  22. package/dist/Expo-AuthSession/utils/tokenRefresh.js +3 -3
  23. package/dist/{chunk-WKE5IW37.js → chunk-AF7VKFEK.js} +20 -11
  24. package/dist/{chunk-52LAPG3S.js → chunk-B7COQI7U.js} +44 -16
  25. package/dist/{chunk-7KZL6S5R.js → chunk-CFY3FFVW.js} +4 -4
  26. package/dist/{chunk-UYO5Y6CJ.js → chunk-DDBEKLVA.js} +1 -1
  27. package/dist/{chunk-IU75T6GM.js → chunk-DDCMUW43.js} +3 -3
  28. package/dist/{chunk-ELBTMDOI.js → chunk-DSDORXK5.js} +3 -3
  29. package/dist/{chunk-W4CNNXDN.js → chunk-GRAW2VSL.js} +4 -1
  30. package/dist/{chunk-PETOX4KF.js → chunk-H623QQTI.js} +1 -1
  31. package/dist/{chunk-IEVUSC3Q.js → chunk-MA2UFH5G.js} +49 -7
  32. package/dist/{chunk-FETRYEKH.js → chunk-VQLMMK6U.js} +5 -2
  33. package/dist/{chunk-YVBJ5RPR.js → chunk-XYBA2PIE.js} +21 -7
  34. package/dist/{chunk-K34WGG6L.js → chunk-ZMR2HMDR.js} +60 -15
  35. package/dist/index.d.ts +0 -3
  36. package/dist/index.js +15 -43
  37. package/package.json +8 -8
  38. package/dist/auth.d.ts +0 -39
  39. package/dist/auth.js +0 -20
  40. package/dist/chunk-7A7RZF24.js +0 -52
  41. package/dist/chunk-DNMYY37N.js +0 -117
  42. package/dist/chunk-GUKC6UGZ.js +0 -0
  43. package/dist/chunk-HAB34YS7.js +0 -0
  44. package/dist/chunk-RBOUHIMW.js +0 -28
  45. package/dist/chunk-XENWB4ZX.js +0 -55
  46. package/dist/components/LoginButton.d.ts +0 -14
  47. package/dist/components/LoginButton.js +0 -10
  48. package/dist/components/index.d.ts +0 -1
  49. package/dist/components/index.js +0 -11
  50. package/dist/hooks/index.d.ts +0 -2
  51. package/dist/hooks/index.js +0 -14
  52. package/dist/hooks/useAccount.d.ts +0 -5
  53. package/dist/hooks/useAccount.js +0 -9
  54. package/dist/hooks/useAuthenticate.d.ts +0 -22
  55. package/dist/hooks/useAuthenticate.js +0 -9
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @equinor/mad-auth
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 07f0174: Authentication package fix to accept scope after migration to expo auth session
8
+
9
+ ## 0.3.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 7bf5e2b: React Native Architecture Upgrade -> Expo sdk upgraded to version 53
14
+
15
+ ### Patch Changes
16
+
17
+ - Updated dependencies [7bf5e2b]
18
+ - @equinor/mad-components@0.23.0
19
+
3
20
  ## 0.2.17
4
21
 
5
22
  ### Patch 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-K34WGG6L.js";
9
+ } from "../../chunk-ZMR2HMDR.js";
10
10
  import "../../chunk-7NSJ6UAV.js";
11
- import "../../chunk-FETRYEKH.js";
12
- import "../../chunk-IEVUSC3Q.js";
13
- import "../../chunk-WKE5IW37.js";
11
+ import "../../chunk-VQLMMK6U.js";
12
+ import "../../chunk-MA2UFH5G.js";
13
+ import "../../chunk-AF7VKFEK.js";
14
14
  import "../../chunk-CWMXXUWU.js";
15
15
  export {
16
16
  authenticateInteractively,
@@ -4,21 +4,21 @@ import {
4
4
  authenticationClientExists,
5
5
  initiateAuthenticationClient,
6
6
  signOut
7
- } from "../../chunk-7KZL6S5R.js";
8
- import "../../chunk-PETOX4KF.js";
7
+ } from "../../chunk-CFY3FFVW.js";
8
+ import "../../chunk-H623QQTI.js";
9
9
  import {
10
10
  getAccountWeb
11
- } from "../../chunk-52LAPG3S.js";
12
- import "../../chunk-W4CNNXDN.js";
11
+ } from "../../chunk-B7COQI7U.js";
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-K34WGG6L.js";
17
+ } from "../../chunk-ZMR2HMDR.js";
17
18
  import "../../chunk-7NSJ6UAV.js";
18
- import "../../chunk-FETRYEKH.js";
19
- import "../../chunk-IEVUSC3Q.js";
20
- import "../../chunk-WKE5IW37.js";
21
- import "../../chunk-7SOSXNKP.js";
19
+ import "../../chunk-VQLMMK6U.js";
20
+ import "../../chunk-MA2UFH5G.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;
@@ -9,6 +10,7 @@ export type InitiateAuthenticationClientConfig = {
9
10
  * @param {InitiateAuthenticationClientConfig} config
10
11
  */
11
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-52LAPG3S.js";
10
- import "../../../chunk-W4CNNXDN.js";
10
+ } from "../../../chunk-B7COQI7U.js";
11
+ import "../../../chunk-GRAW2VSL.js";
11
12
  import "../../../chunk-MWXZHQN3.js";
12
13
  import "../../../chunk-7SOSXNKP.js";
14
+ import "../../../chunk-MA2UFH5G.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
@@ -1,22 +1,25 @@
1
1
  import {
2
2
  web_default
3
- } from "../../../chunk-PETOX4KF.js";
3
+ } from "../../../chunk-H623QQTI.js";
4
4
  import {
5
5
  _resetWeb,
6
6
  authenticateInteractivelyWeb,
7
7
  authenticateSilentlyWeb,
8
8
  authenticationClientExistsWeb,
9
+ ensurePcaInitialized,
9
10
  getAccountWeb,
10
11
  initiateAuthenticationClientWeb,
11
12
  signOutWeb
12
- } from "../../../chunk-52LAPG3S.js";
13
- import "../../../chunk-W4CNNXDN.js";
13
+ } from "../../../chunk-B7COQI7U.js";
14
+ import "../../../chunk-GRAW2VSL.js";
14
15
  import {
15
16
  Ios_MSALWebviewType,
16
17
  Ios_ModalPresentationStyle,
17
18
  MSALPromptType
18
19
  } from "../../../chunk-MWXZHQN3.js";
19
20
  import "../../../chunk-7SOSXNKP.js";
21
+ import "../../../chunk-MA2UFH5G.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
@@ -3,7 +3,7 @@ export declare class PublicClientApplication implements IPublicClientApplication
3
3
  private readonly config;
4
4
  private _pca;
5
5
  constructor(config: MSALConfiguration);
6
- init(): this;
6
+ init(): Promise<this>;
7
7
  acquireToken(params: MSALInteractiveParams): Promise<MSALResult | undefined>;
8
8
  acquireTokenSilent(params: MSALSilentParams): Promise<MSALResult | undefined>;
9
9
  getAccounts(): Promise<MSALAccount[]>;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  PublicClientApplication
3
- } from "../../../chunk-W4CNNXDN.js";
3
+ } from "../../../chunk-GRAW2VSL.js";
4
4
  import "../../../chunk-MWXZHQN3.js";
5
5
  import "../../../chunk-CWMXXUWU.js";
6
6
  export {
@@ -1,4 +1,15 @@
1
1
  import React from "react";
2
- import { LoginButtonProps } from "../../components";
2
+ import { ButtonProps } from "@equinor/mad-components";
3
+ import { AuthenticationType } from "../hooks/useAuthenticate";
3
4
  import "core-js/stable/atob";
5
+ import { MadAuthenticationResult } from "../../types";
6
+ export type LoginButtonProps = Omit<ButtonProps, "onPress" | "loading" | "disabled" | "title"> & {
7
+ clientId: string;
8
+ redirectUri: string;
9
+ onAuthenticationSuccessful: (res: MadAuthenticationResult, type: AuthenticationType) => void;
10
+ onAuthenticationFailed: (error: unknown) => void;
11
+ title?: ButtonProps["title"];
12
+ scopes?: string[];
13
+ enableAutomaticAuthentication?: boolean;
14
+ };
4
15
  export declare const LoginButton: ({ clientId, redirectUri, onAuthenticationSuccessful, onAuthenticationFailed, enableAutomaticAuthentication, scopes, title, ...rest }: LoginButtonProps) => React.JSX.Element;
@@ -1,18 +1,18 @@
1
1
  import {
2
2
  LoginButton
3
- } from "../../chunk-UYO5Y6CJ.js";
4
- import "../../chunk-ELBTMDOI.js";
5
- import "../../chunk-7KZL6S5R.js";
6
- import "../../chunk-PETOX4KF.js";
7
- import "../../chunk-52LAPG3S.js";
8
- import "../../chunk-W4CNNXDN.js";
3
+ } from "../../chunk-DDBEKLVA.js";
4
+ import "../../chunk-DSDORXK5.js";
5
+ import "../../chunk-CFY3FFVW.js";
6
+ import "../../chunk-H623QQTI.js";
7
+ import "../../chunk-B7COQI7U.js";
8
+ import "../../chunk-GRAW2VSL.js";
9
9
  import "../../chunk-MWXZHQN3.js";
10
- import "../../chunk-K34WGG6L.js";
11
- import "../../chunk-7NSJ6UAV.js";
12
- import "../../chunk-FETRYEKH.js";
13
- import "../../chunk-IEVUSC3Q.js";
14
- import "../../chunk-WKE5IW37.js";
15
10
  import "../../chunk-7SOSXNKP.js";
11
+ import "../../chunk-ZMR2HMDR.js";
12
+ import "../../chunk-7NSJ6UAV.js";
13
+ import "../../chunk-VQLMMK6U.js";
14
+ import "../../chunk-MA2UFH5G.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-IU75T6GM.js";
4
- import "../../chunk-7KZL6S5R.js";
5
- import "../../chunk-PETOX4KF.js";
6
- import "../../chunk-52LAPG3S.js";
7
- import "../../chunk-W4CNNXDN.js";
3
+ } from "../../chunk-DDCMUW43.js";
4
+ import "../../chunk-CFY3FFVW.js";
5
+ import "../../chunk-H623QQTI.js";
6
+ import "../../chunk-B7COQI7U.js";
7
+ import "../../chunk-GRAW2VSL.js";
8
8
  import "../../chunk-MWXZHQN3.js";
9
- import "../../chunk-K34WGG6L.js";
10
- import "../../chunk-7NSJ6UAV.js";
11
- import "../../chunk-FETRYEKH.js";
12
- import "../../chunk-IEVUSC3Q.js";
13
- import "../../chunk-WKE5IW37.js";
14
9
  import "../../chunk-7SOSXNKP.js";
10
+ import "../../chunk-ZMR2HMDR.js";
11
+ import "../../chunk-7NSJ6UAV.js";
12
+ import "../../chunk-VQLMMK6U.js";
13
+ import "../../chunk-MA2UFH5G.js";
14
+ import "../../chunk-AF7VKFEK.js";
15
15
  import "../../chunk-CWMXXUWU.js";
16
16
  export {
17
17
  useAccount
@@ -1,12 +1,12 @@
1
1
  import { AuthRequestConfig } from "expo-auth-session";
2
2
  import { MadAuthenticationResult } from "../../types";
3
- import { AuthenticationType } from "../../hooks";
4
3
  type useExpoAuthenticateProps = {
5
4
  config: AuthRequestConfig;
6
5
  onAuthenticationSuccessful: (res: MadAuthenticationResult, type: AuthenticationType) => void;
7
6
  onAuthenticationFailed: (error: unknown) => void;
8
7
  enableAutomaticAuthentication?: boolean;
9
8
  };
9
+ export type AuthenticationType = "AUTOMATIC" | "MANUAL";
10
10
  /**
11
11
  * initialize the authentication client, and authenticate the user
12
12
  * @param {UseExpoAuthenticateProps} params params for client initialization and authentication flow
@@ -1,17 +1,17 @@
1
1
  import {
2
2
  useAuthenticate
3
- } from "../../chunk-ELBTMDOI.js";
4
- import "../../chunk-7KZL6S5R.js";
5
- import "../../chunk-PETOX4KF.js";
6
- import "../../chunk-52LAPG3S.js";
7
- import "../../chunk-W4CNNXDN.js";
3
+ } from "../../chunk-DSDORXK5.js";
4
+ import "../../chunk-CFY3FFVW.js";
5
+ import "../../chunk-H623QQTI.js";
6
+ import "../../chunk-B7COQI7U.js";
7
+ import "../../chunk-GRAW2VSL.js";
8
8
  import "../../chunk-MWXZHQN3.js";
9
- import "../../chunk-K34WGG6L.js";
10
- import "../../chunk-7NSJ6UAV.js";
11
- import "../../chunk-FETRYEKH.js";
12
- import "../../chunk-IEVUSC3Q.js";
13
- import "../../chunk-WKE5IW37.js";
14
9
  import "../../chunk-7SOSXNKP.js";
10
+ import "../../chunk-ZMR2HMDR.js";
11
+ import "../../chunk-7NSJ6UAV.js";
12
+ import "../../chunk-VQLMMK6U.js";
13
+ import "../../chunk-MA2UFH5G.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-YVBJ5RPR.js";
1
+ import "../chunk-XYBA2PIE.js";
2
2
  import {
3
3
  useAccount
4
- } from "../chunk-IU75T6GM.js";
4
+ } from "../chunk-DDCMUW43.js";
5
+ import "../chunk-NP4GJ5X5.js";
5
6
  import {
6
7
  LoginButton
7
- } from "../chunk-UYO5Y6CJ.js";
8
+ } from "../chunk-DDBEKLVA.js";
8
9
  import {
9
10
  useAuthenticate
10
- } from "../chunk-ELBTMDOI.js";
11
+ } from "../chunk-DSDORXK5.js";
11
12
  import {
12
13
  authenticateInteractively,
13
14
  authenticateSilently,
14
15
  authenticationClientExists,
15
16
  initiateAuthenticationClient,
16
17
  signOut
17
- } from "../chunk-7KZL6S5R.js";
18
- import "../chunk-PETOX4KF.js";
18
+ } from "../chunk-CFY3FFVW.js";
19
+ import "../chunk-H623QQTI.js";
19
20
  import {
20
21
  getAccountWeb
21
- } from "../chunk-52LAPG3S.js";
22
- import "../chunk-W4CNNXDN.js";
22
+ } from "../chunk-B7COQI7U.js";
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-K34WGG6L.js";
28
+ } from "../chunk-ZMR2HMDR.js";
27
29
  import "../chunk-7NSJ6UAV.js";
28
- import "../chunk-FETRYEKH.js";
30
+ import "../chunk-VQLMMK6U.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-IEVUSC3Q.js";
44
- import "../chunk-WKE5IW37.js";
45
- import "../chunk-NP4GJ5X5.js";
46
- import "../chunk-7SOSXNKP.js";
52
+ } from "../chunk-MA2UFH5G.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
  */
@@ -12,7 +13,7 @@ export declare const useAuth: import("zustand").UseBoundStore<Omit<Omit<import("
12
13
  persist: {
13
14
  setOptions: (options: Partial<import("zustand/middleware").PersistOptions<AuthState, unknown>>) => void;
14
15
  clearStorage: () => void;
15
- rehydrate: () => void | Promise<void>;
16
+ rehydrate: () => Promise<void> | void;
16
17
  hasHydrated: () => boolean;
17
18
  onHydrate: (fn: (state: AuthState) => void) => () => void;
18
19
  onFinishHydration: (fn: (state: AuthState) => void) => () => void;
@@ -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-IEVUSC3Q.js";
16
- import "../../chunk-WKE5IW37.js";
22
+ } from "../../chunk-MA2UFH5G.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-WKE5IW37.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-FETRYEKH.js";
4
- import "../../chunk-IEVUSC3Q.js";
5
- import "../../chunk-WKE5IW37.js";
3
+ } from "../../chunk-VQLMMK6U.js";
4
+ import "../../chunk-MA2UFH5G.js";
5
+ import "../../chunk-AF7VKFEK.js";
6
6
  import "../../chunk-CWMXXUWU.js";
7
7
  export {
8
8
  tokenRefresh
@@ -7,14 +7,15 @@ 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
- var encrypt = (key, value) => __async(void 0, null, function* () {
10
+ import { Platform } from "react-native";
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));
13
14
  const encryptedBytes = cipher.encrypt(aesjs.utils.utf8.toBytes(value));
14
15
  yield SecureStore.setItemAsync(key, aesjs.utils.hex.fromBytes(encryptionKey));
15
16
  return aesjs.utils.hex.fromBytes(encryptedBytes);
16
17
  });
17
- var decrypt = (key, value) => __async(void 0, null, function* () {
18
+ var decrypt = (key, value) => __async(null, null, function* () {
18
19
  const encryptionKeyHex = yield SecureStore.getItemAsync(key);
19
20
  if (!encryptionKeyHex) {
20
21
  return encryptionKeyHex;
@@ -26,20 +27,28 @@ var decrypt = (key, value) => __async(void 0, null, function* () {
26
27
  const decryptedBytes = cipher.decrypt(aesjs.utils.hex.toBytes(value));
27
28
  return aesjs.utils.utf8.fromBytes(decryptedBytes);
28
29
  });
29
- var getItem = (key) => __async(void 0, null, function* () {
30
- const encrypted = yield AsyncStorage.getItem(key);
31
- if (!encrypted) {
32
- return encrypted;
30
+ var getItem = (key) => __async(null, null, function* () {
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
- var removeItem = (key) => __async(void 0, null, function* () {
41
+ var removeItem = (key) => __async(null, null, function* () {
37
42
  yield AsyncStorage.removeItem(key);
38
43
  yield SecureStore.deleteItemAsync(key);
39
44
  });
40
- var setItem = (key, value) => __async(void 0, null, function* () {
41
- const encrypted = yield encrypt(key, value);
42
- yield AsyncStorage.setItem(key, encrypted);
45
+ var setItem = (key, value) => __async(null, null, function* () {
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 {