@equinor/mad-auth 0.2.16 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/dist/Expo-AuthSession/authenticationHandler/auth.js +4 -4
- package/dist/Expo-AuthSession/authenticationHandler/index.d.ts +1 -1
- package/dist/Expo-AuthSession/authenticationHandler/index.js +8 -8
- package/dist/Expo-AuthSession/authenticationHandler/web/authWeb.d.ts +1 -1
- package/dist/Expo-AuthSession/authenticationHandler/web/authWeb.js +2 -2
- package/dist/Expo-AuthSession/authenticationHandler/web/index.js +3 -3
- package/dist/Expo-AuthSession/authenticationHandler/web/publicClientApplication.d.ts +1 -1
- package/dist/Expo-AuthSession/authenticationHandler/web/publicClientApplication.js +1 -1
- package/dist/Expo-AuthSession/components/LoginButton.d.ts +12 -1
- package/dist/Expo-AuthSession/components/LoginButton.js +10 -10
- package/dist/Expo-AuthSession/hooks/useAccount.js +9 -9
- package/dist/Expo-AuthSession/hooks/useAuthenticate.d.ts +1 -1
- package/dist/Expo-AuthSession/hooks/useAuthenticate.js +9 -9
- package/dist/Expo-AuthSession/index.js +14 -14
- package/dist/Expo-AuthSession/store/authStore.d.ts +1 -1
- package/dist/Expo-AuthSession/store/authStore.js +2 -2
- package/dist/Expo-AuthSession/store/encryption.js +1 -1
- package/dist/Expo-AuthSession/utils/tokenRefresh.js +3 -3
- package/dist/auth.d.ts +0 -39
- package/dist/auth.js +0 -20
- package/dist/{chunk-IU75T6GM.js → chunk-5RSIJ5AN.js} +3 -3
- package/dist/{chunk-K34WGG6L.js → chunk-BDLB5HOI.js} +4 -4
- package/dist/{chunk-IEVUSC3Q.js → chunk-BZJJPLOA.js} +1 -1
- package/dist/{chunk-WKE5IW37.js → chunk-FJEJBJRU.js} +5 -5
- package/dist/{chunk-W4CNNXDN.js → chunk-GRAW2VSL.js} +4 -1
- package/dist/{chunk-PETOX4KF.js → chunk-H623QQTI.js} +1 -1
- package/dist/{chunk-52LAPG3S.js → chunk-LT4NDIEQ.js} +19 -17
- package/dist/{chunk-UYO5Y6CJ.js → chunk-PGRO37AZ.js} +1 -1
- package/dist/{chunk-ELBTMDOI.js → chunk-T5YGX52R.js} +4 -4
- package/dist/{chunk-YGHNEFH2.js → chunk-TSYWYSXA.js} +9 -9
- package/dist/{chunk-7KZL6S5R.js → chunk-UGY2AUZX.js} +11 -6
- package/dist/{chunk-FETRYEKH.js → chunk-X2FA4SVJ.js} +2 -2
- package/dist/components/LoginButton.d.ts +0 -14
- package/dist/components/LoginButton.js +0 -10
- package/dist/components/index.d.ts +0 -1
- package/dist/components/index.js +0 -11
- package/dist/hooks/index.d.ts +0 -2
- package/dist/hooks/index.js +0 -14
- package/dist/hooks/useAccount.d.ts +0 -5
- package/dist/hooks/useAccount.js +0 -9
- package/dist/hooks/useAuthenticate.d.ts +0 -22
- package/dist/hooks/useAuthenticate.js +0 -9
- package/dist/index.d.ts +0 -3
- package/dist/index.js +13 -41
- package/package.json +6 -7
- package/dist/chunk-7A7RZF24.js +0 -52
- package/dist/chunk-DNMYY37N.js +0 -117
- package/dist/chunk-GUKC6UGZ.js +0 -0
- package/dist/chunk-HAB34YS7.js +0 -0
- package/dist/chunk-RBOUHIMW.js +0 -28
- package/dist/chunk-XENWB4ZX.js +0 -55
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @equinor/mad-auth
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7bf5e2b: React Native Architecture Upgrade -> Expo sdk upgraded to version 53
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [7bf5e2b]
|
|
12
|
+
- @equinor/mad-components@0.23.0
|
|
13
|
+
|
|
14
|
+
## 0.2.17
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- Updated dependencies [30521d3]
|
|
19
|
+
- @equinor/mad-components@0.22.0
|
|
20
|
+
|
|
3
21
|
## 0.2.16
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
|
@@ -6,11 +6,11 @@ import {
|
|
|
6
6
|
initiateAuthenticationClient,
|
|
7
7
|
reset,
|
|
8
8
|
signOut
|
|
9
|
-
} from "../../chunk-
|
|
9
|
+
} from "../../chunk-BDLB5HOI.js";
|
|
10
10
|
import "../../chunk-7NSJ6UAV.js";
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
11
|
+
import "../../chunk-X2FA4SVJ.js";
|
|
12
|
+
import "../../chunk-BZJJPLOA.js";
|
|
13
|
+
import "../../chunk-FJEJBJRU.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) => void
|
|
7
|
+
export declare const initiateAuthenticationClient: (config: AuthRequestConfig, discovery: DiscoveryDocument) => Promise<void>;
|
|
8
8
|
export declare const authenticationClientExists: () => boolean;
|
|
@@ -4,20 +4,20 @@ import {
|
|
|
4
4
|
authenticationClientExists,
|
|
5
5
|
initiateAuthenticationClient,
|
|
6
6
|
signOut
|
|
7
|
-
} from "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
7
|
+
} from "../../chunk-UGY2AUZX.js";
|
|
8
|
+
import "../../chunk-H623QQTI.js";
|
|
9
9
|
import {
|
|
10
10
|
getAccountWeb
|
|
11
|
-
} from "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
11
|
+
} from "../../chunk-LT4NDIEQ.js";
|
|
12
|
+
import "../../chunk-GRAW2VSL.js";
|
|
13
13
|
import "../../chunk-MWXZHQN3.js";
|
|
14
14
|
import {
|
|
15
15
|
getAccount
|
|
16
|
-
} from "../../chunk-
|
|
16
|
+
} from "../../chunk-BDLB5HOI.js";
|
|
17
17
|
import "../../chunk-7NSJ6UAV.js";
|
|
18
|
-
import "../../chunk-
|
|
19
|
-
import "../../chunk-
|
|
20
|
-
import "../../chunk-
|
|
18
|
+
import "../../chunk-X2FA4SVJ.js";
|
|
19
|
+
import "../../chunk-BZJJPLOA.js";
|
|
20
|
+
import "../../chunk-FJEJBJRU.js";
|
|
21
21
|
import "../../chunk-7SOSXNKP.js";
|
|
22
22
|
import "../../chunk-CWMXXUWU.js";
|
|
23
23
|
export {
|
|
@@ -8,7 +8,7 @@ export type InitiateAuthenticationClientConfig = {
|
|
|
8
8
|
* Initiate the authentication client
|
|
9
9
|
* @param {InitiateAuthenticationClientConfig} config
|
|
10
10
|
*/
|
|
11
|
-
export declare function initiateAuthenticationClientWeb({ clientId, redirectUri, authority, }: InitiateAuthenticationClientConfig): void
|
|
11
|
+
export declare function initiateAuthenticationClientWeb({ clientId, redirectUri, authority, }: InitiateAuthenticationClientConfig): Promise<void>;
|
|
12
12
|
/**
|
|
13
13
|
* Check if the authentication client exists
|
|
14
14
|
* @returns {boolean} whether the authentication client exists
|
|
@@ -6,8 +6,8 @@ import {
|
|
|
6
6
|
getAccountWeb,
|
|
7
7
|
initiateAuthenticationClientWeb,
|
|
8
8
|
signOutWeb
|
|
9
|
-
} from "../../../chunk-
|
|
10
|
-
import "../../../chunk-
|
|
9
|
+
} from "../../../chunk-LT4NDIEQ.js";
|
|
10
|
+
import "../../../chunk-GRAW2VSL.js";
|
|
11
11
|
import "../../../chunk-MWXZHQN3.js";
|
|
12
12
|
import "../../../chunk-7SOSXNKP.js";
|
|
13
13
|
import "../../../chunk-CWMXXUWU.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
web_default
|
|
3
|
-
} from "../../../chunk-
|
|
3
|
+
} from "../../../chunk-H623QQTI.js";
|
|
4
4
|
import {
|
|
5
5
|
_resetWeb,
|
|
6
6
|
authenticateInteractivelyWeb,
|
|
@@ -9,8 +9,8 @@ import {
|
|
|
9
9
|
getAccountWeb,
|
|
10
10
|
initiateAuthenticationClientWeb,
|
|
11
11
|
signOutWeb
|
|
12
|
-
} from "../../../chunk-
|
|
13
|
-
import "../../../chunk-
|
|
12
|
+
} from "../../../chunk-LT4NDIEQ.js";
|
|
13
|
+
import "../../../chunk-GRAW2VSL.js";
|
|
14
14
|
import {
|
|
15
15
|
Ios_MSALWebviewType,
|
|
16
16
|
Ios_ModalPresentationStyle,
|
|
@@ -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,4 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
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,17 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LoginButton
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
8
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-PGRO37AZ.js";
|
|
4
|
+
import "../../chunk-T5YGX52R.js";
|
|
5
|
+
import "../../chunk-UGY2AUZX.js";
|
|
6
|
+
import "../../chunk-H623QQTI.js";
|
|
7
|
+
import "../../chunk-LT4NDIEQ.js";
|
|
8
|
+
import "../../chunk-GRAW2VSL.js";
|
|
9
9
|
import "../../chunk-MWXZHQN3.js";
|
|
10
|
-
import "../../chunk-
|
|
10
|
+
import "../../chunk-BDLB5HOI.js";
|
|
11
11
|
import "../../chunk-7NSJ6UAV.js";
|
|
12
|
-
import "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
14
|
-
import "../../chunk-
|
|
12
|
+
import "../../chunk-X2FA4SVJ.js";
|
|
13
|
+
import "../../chunk-BZJJPLOA.js";
|
|
14
|
+
import "../../chunk-FJEJBJRU.js";
|
|
15
15
|
import "../../chunk-7SOSXNKP.js";
|
|
16
16
|
import "../../chunk-CWMXXUWU.js";
|
|
17
17
|
export {
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useAccount
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-5RSIJ5AN.js";
|
|
4
|
+
import "../../chunk-UGY2AUZX.js";
|
|
5
|
+
import "../../chunk-H623QQTI.js";
|
|
6
|
+
import "../../chunk-LT4NDIEQ.js";
|
|
7
|
+
import "../../chunk-GRAW2VSL.js";
|
|
8
8
|
import "../../chunk-MWXZHQN3.js";
|
|
9
|
-
import "../../chunk-
|
|
9
|
+
import "../../chunk-BDLB5HOI.js";
|
|
10
10
|
import "../../chunk-7NSJ6UAV.js";
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
11
|
+
import "../../chunk-X2FA4SVJ.js";
|
|
12
|
+
import "../../chunk-BZJJPLOA.js";
|
|
13
|
+
import "../../chunk-FJEJBJRU.js";
|
|
14
14
|
import "../../chunk-7SOSXNKP.js";
|
|
15
15
|
import "../../chunk-CWMXXUWU.js";
|
|
16
16
|
export {
|
|
@@ -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,16 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useAuthenticate
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
6
|
-
import "../../chunk-
|
|
7
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-T5YGX52R.js";
|
|
4
|
+
import "../../chunk-UGY2AUZX.js";
|
|
5
|
+
import "../../chunk-H623QQTI.js";
|
|
6
|
+
import "../../chunk-LT4NDIEQ.js";
|
|
7
|
+
import "../../chunk-GRAW2VSL.js";
|
|
8
8
|
import "../../chunk-MWXZHQN3.js";
|
|
9
|
-
import "../../chunk-
|
|
9
|
+
import "../../chunk-BDLB5HOI.js";
|
|
10
10
|
import "../../chunk-7NSJ6UAV.js";
|
|
11
|
-
import "../../chunk-
|
|
12
|
-
import "../../chunk-
|
|
13
|
-
import "../../chunk-
|
|
11
|
+
import "../../chunk-X2FA4SVJ.js";
|
|
12
|
+
import "../../chunk-BZJJPLOA.js";
|
|
13
|
+
import "../../chunk-FJEJBJRU.js";
|
|
14
14
|
import "../../chunk-7SOSXNKP.js";
|
|
15
15
|
import "../../chunk-CWMXXUWU.js";
|
|
16
16
|
export {
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import "../chunk-
|
|
2
|
-
import {
|
|
3
|
-
LoginButton
|
|
4
|
-
} from "../chunk-UYO5Y6CJ.js";
|
|
1
|
+
import "../chunk-TSYWYSXA.js";
|
|
5
2
|
import {
|
|
6
3
|
useAccount
|
|
7
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-5RSIJ5AN.js";
|
|
5
|
+
import {
|
|
6
|
+
LoginButton
|
|
7
|
+
} from "../chunk-PGRO37AZ.js";
|
|
8
8
|
import {
|
|
9
9
|
useAuthenticate
|
|
10
|
-
} from "../chunk-
|
|
10
|
+
} from "../chunk-T5YGX52R.js";
|
|
11
11
|
import {
|
|
12
12
|
authenticateInteractively,
|
|
13
13
|
authenticateSilently,
|
|
14
14
|
authenticationClientExists,
|
|
15
15
|
initiateAuthenticationClient,
|
|
16
16
|
signOut
|
|
17
|
-
} from "../chunk-
|
|
18
|
-
import "../chunk-
|
|
17
|
+
} from "../chunk-UGY2AUZX.js";
|
|
18
|
+
import "../chunk-H623QQTI.js";
|
|
19
19
|
import {
|
|
20
20
|
getAccountWeb
|
|
21
|
-
} from "../chunk-
|
|
22
|
-
import "../chunk-
|
|
21
|
+
} from "../chunk-LT4NDIEQ.js";
|
|
22
|
+
import "../chunk-GRAW2VSL.js";
|
|
23
23
|
import "../chunk-MWXZHQN3.js";
|
|
24
24
|
import {
|
|
25
25
|
getAccount
|
|
26
|
-
} from "../chunk-
|
|
26
|
+
} from "../chunk-BDLB5HOI.js";
|
|
27
27
|
import "../chunk-7NSJ6UAV.js";
|
|
28
|
-
import "../chunk-
|
|
28
|
+
import "../chunk-X2FA4SVJ.js";
|
|
29
29
|
import {
|
|
30
30
|
getConfig,
|
|
31
31
|
getDiscovery,
|
|
@@ -40,8 +40,8 @@ import {
|
|
|
40
40
|
setToken,
|
|
41
41
|
setUserData,
|
|
42
42
|
useAuth
|
|
43
|
-
} from "../chunk-
|
|
44
|
-
import "../chunk-
|
|
43
|
+
} from "../chunk-BZJJPLOA.js";
|
|
44
|
+
import "../chunk-FJEJBJRU.js";
|
|
45
45
|
import "../chunk-NP4GJ5X5.js";
|
|
46
46
|
import "../chunk-7SOSXNKP.js";
|
|
47
47
|
import "../chunk-CWMXXUWU.js";
|
|
@@ -12,7 +12,7 @@ export declare const useAuth: import("zustand").UseBoundStore<Omit<Omit<import("
|
|
|
12
12
|
persist: {
|
|
13
13
|
setOptions: (options: Partial<import("zustand/middleware").PersistOptions<AuthState, unknown>>) => void;
|
|
14
14
|
clearStorage: () => void;
|
|
15
|
-
rehydrate: () => void |
|
|
15
|
+
rehydrate: () => Promise<void> | void;
|
|
16
16
|
hasHydrated: () => boolean;
|
|
17
17
|
onHydrate: (fn: (state: AuthState) => void) => () => void;
|
|
18
18
|
onFinishHydration: (fn: (state: AuthState) => void) => () => void;
|
|
@@ -12,8 +12,8 @@ import {
|
|
|
12
12
|
setToken,
|
|
13
13
|
setUserData,
|
|
14
14
|
useAuth
|
|
15
|
-
} from "../../chunk-
|
|
16
|
-
import "../../chunk-
|
|
15
|
+
} from "../../chunk-BZJJPLOA.js";
|
|
16
|
+
import "../../chunk-FJEJBJRU.js";
|
|
17
17
|
import "../../chunk-CWMXXUWU.js";
|
|
18
18
|
export {
|
|
19
19
|
getConfig,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
tokenRefresh
|
|
3
|
-
} from "../../chunk-
|
|
4
|
-
import "../../chunk-
|
|
5
|
-
import "../../chunk-
|
|
3
|
+
} from "../../chunk-X2FA4SVJ.js";
|
|
4
|
+
import "../../chunk-BZJJPLOA.js";
|
|
5
|
+
import "../../chunk-FJEJBJRU.js";
|
|
6
6
|
import "../../chunk-CWMXXUWU.js";
|
|
7
7
|
export {
|
|
8
8
|
tokenRefresh
|
package/dist/auth.d.ts
CHANGED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { MadAccount, MadAuthenticationResult } from "./types";
|
|
2
|
-
export type InitiateAuthenticationClientConfig = {
|
|
3
|
-
clientId: string;
|
|
4
|
-
redirectUri: string;
|
|
5
|
-
authority?: string;
|
|
6
|
-
};
|
|
7
|
-
/**
|
|
8
|
-
* Initiate the authentication client
|
|
9
|
-
* @param {InitiateAuthenticationClientConfig} config
|
|
10
|
-
*/
|
|
11
|
-
export declare function initiateAuthenticationClient({ clientId, redirectUri, authority, }: InitiateAuthenticationClientConfig): Promise<void>;
|
|
12
|
-
/**
|
|
13
|
-
* Check if the authentication client exists
|
|
14
|
-
* @returns {boolean} whether the authentication client exists
|
|
15
|
-
*/
|
|
16
|
-
export declare function authenticationClientExists(): boolean;
|
|
17
|
-
/**
|
|
18
|
-
* Authenticate interactively. This will open an in-app browser, or the Microsoft Authenticator app if the
|
|
19
|
-
* user has it installed
|
|
20
|
-
* @param scopes an array of scopes
|
|
21
|
-
* @returns {MadAuthenticationResult | null} an object containing the access token and the account, or null
|
|
22
|
-
*/
|
|
23
|
-
export declare function authenticateInteractively(scopes: string[]): Promise<MadAuthenticationResult | null>;
|
|
24
|
-
export declare function getAccount(): Promise<MadAccount | null>;
|
|
25
|
-
/**
|
|
26
|
-
* Authenticate silently.
|
|
27
|
-
* @param scopes an array of scopes
|
|
28
|
-
* @returns {MadAuthenticationResult | null} an object containing the access token and the account, or null
|
|
29
|
-
*/
|
|
30
|
-
export declare function authenticateSilently(scopes: string[]): Promise<MadAuthenticationResult | null>;
|
|
31
|
-
/**
|
|
32
|
-
* Sign out the account.
|
|
33
|
-
* @returns {boolean} whether we successfully signed out.
|
|
34
|
-
*/
|
|
35
|
-
export declare function signOut(): Promise<boolean>;
|
|
36
|
-
/**
|
|
37
|
-
*
|
|
38
|
-
*/
|
|
39
|
-
export declare function _reset(): void;
|
package/dist/auth.js
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
_reset,
|
|
3
|
-
authenticateInteractively,
|
|
4
|
-
authenticateSilently,
|
|
5
|
-
authenticationClientExists,
|
|
6
|
-
getAccount,
|
|
7
|
-
initiateAuthenticationClient,
|
|
8
|
-
signOut
|
|
9
|
-
} from "./chunk-DNMYY37N.js";
|
|
10
|
-
import "./chunk-7SOSXNKP.js";
|
|
11
|
-
import "./chunk-CWMXXUWU.js";
|
|
12
|
-
export {
|
|
13
|
-
_reset,
|
|
14
|
-
authenticateInteractively,
|
|
15
|
-
authenticateSilently,
|
|
16
|
-
authenticationClientExists,
|
|
17
|
-
getAccount,
|
|
18
|
-
initiateAuthenticationClient,
|
|
19
|
-
signOut
|
|
20
|
-
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getAccountWeb
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LT4NDIEQ.js";
|
|
4
4
|
import {
|
|
5
5
|
useAuth
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-BZJJPLOA.js";
|
|
7
7
|
import {
|
|
8
8
|
__async
|
|
9
9
|
} from "./chunk-CWMXXUWU.js";
|
|
@@ -18,7 +18,7 @@ var useAccountNative = () => {
|
|
|
18
18
|
var useAccountWeb = () => {
|
|
19
19
|
const [account, setAccount] = useState();
|
|
20
20
|
useEffect(() => {
|
|
21
|
-
const getAndSetAccount = () => __async(
|
|
21
|
+
const getAndSetAccount = () => __async(null, null, function* () {
|
|
22
22
|
try {
|
|
23
23
|
const account2 = yield getAccountWeb();
|
|
24
24
|
setAccount(account2);
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-7NSJ6UAV.js";
|
|
4
4
|
import {
|
|
5
5
|
tokenRefresh
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-X2FA4SVJ.js";
|
|
7
7
|
import {
|
|
8
8
|
getConfig,
|
|
9
9
|
getDiscovery,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
setDiscovery,
|
|
18
18
|
setToken,
|
|
19
19
|
setUserData
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-BZJJPLOA.js";
|
|
21
21
|
import {
|
|
22
22
|
__async
|
|
23
23
|
} from "./chunk-CWMXXUWU.js";
|
|
@@ -36,7 +36,7 @@ function initiateAuthenticationClient(config, discovery) {
|
|
|
36
36
|
function authenticationClientExists() {
|
|
37
37
|
return !!getConfig() && !!getDiscovery();
|
|
38
38
|
}
|
|
39
|
-
var authenticateInteractively = () => __async(
|
|
39
|
+
var authenticateInteractively = () => __async(null, null, function* () {
|
|
40
40
|
const discovery = getDiscovery();
|
|
41
41
|
const config = getConfig();
|
|
42
42
|
if (!discovery || !config) return null;
|
|
@@ -58,7 +58,7 @@ var authenticateInteractively = () => __async(void 0, null, function* () {
|
|
|
58
58
|
}
|
|
59
59
|
return null;
|
|
60
60
|
});
|
|
61
|
-
var authenticateSilently = () => __async(
|
|
61
|
+
var authenticateSilently = () => __async(null, null, function* () {
|
|
62
62
|
const userData = getUserData();
|
|
63
63
|
const token = getToken();
|
|
64
64
|
if (!userData || !token) return null;
|
|
@@ -7,14 +7,14 @@ 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(
|
|
10
|
+
var encrypt = (key, value) => __async(null, null, function* () {
|
|
11
11
|
const encryptionKey = crypto.getRandomValues(new Uint8Array(256 / 8));
|
|
12
12
|
const cipher = new aesjs.ModeOfOperation.ctr(encryptionKey, new aesjs.Counter(1));
|
|
13
13
|
const encryptedBytes = cipher.encrypt(aesjs.utils.utf8.toBytes(value));
|
|
14
14
|
yield SecureStore.setItemAsync(key, aesjs.utils.hex.fromBytes(encryptionKey));
|
|
15
15
|
return aesjs.utils.hex.fromBytes(encryptedBytes);
|
|
16
16
|
});
|
|
17
|
-
var decrypt = (key, value) => __async(
|
|
17
|
+
var decrypt = (key, value) => __async(null, null, function* () {
|
|
18
18
|
const encryptionKeyHex = yield SecureStore.getItemAsync(key);
|
|
19
19
|
if (!encryptionKeyHex) {
|
|
20
20
|
return encryptionKeyHex;
|
|
@@ -26,18 +26,18 @@ var decrypt = (key, value) => __async(void 0, null, function* () {
|
|
|
26
26
|
const decryptedBytes = cipher.decrypt(aesjs.utils.hex.toBytes(value));
|
|
27
27
|
return aesjs.utils.utf8.fromBytes(decryptedBytes);
|
|
28
28
|
});
|
|
29
|
-
var getItem = (key) => __async(
|
|
29
|
+
var getItem = (key) => __async(null, null, function* () {
|
|
30
30
|
const encrypted = yield AsyncStorage.getItem(key);
|
|
31
31
|
if (!encrypted) {
|
|
32
32
|
return encrypted;
|
|
33
33
|
}
|
|
34
34
|
return yield decrypt(key, encrypted);
|
|
35
35
|
});
|
|
36
|
-
var removeItem = (key) => __async(
|
|
36
|
+
var removeItem = (key) => __async(null, null, function* () {
|
|
37
37
|
yield AsyncStorage.removeItem(key);
|
|
38
38
|
yield SecureStore.deleteItemAsync(key);
|
|
39
39
|
});
|
|
40
|
-
var setItem = (key, value) => __async(
|
|
40
|
+
var setItem = (key, value) => __async(null, null, function* () {
|
|
41
41
|
const encrypted = yield encrypt(key, value);
|
|
42
42
|
yield AsyncStorage.setItem(key, encrypted);
|
|
43
43
|
});
|
|
@@ -13,7 +13,10 @@ var PublicClientApplication = class {
|
|
|
13
13
|
this._pca = new MSALPublicClientApplication(this.config);
|
|
14
14
|
}
|
|
15
15
|
init() {
|
|
16
|
-
return this
|
|
16
|
+
return __async(this, null, function* () {
|
|
17
|
+
yield this._pca.initialize();
|
|
18
|
+
return this;
|
|
19
|
+
});
|
|
17
20
|
}
|
|
18
21
|
acquireToken(params) {
|
|
19
22
|
return __async(this, null, function* () {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PublicClientApplication
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GRAW2VSL.js";
|
|
4
4
|
import {
|
|
5
5
|
getMadAccount,
|
|
6
6
|
getMadAuthenticationResult
|
|
@@ -30,22 +30,24 @@ function _getMadAccountFromMSAL() {
|
|
|
30
30
|
return null;
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
|
-
function initiateAuthenticationClientWeb({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
});
|
|
49
51
|
}
|
|
50
52
|
function authenticationClientExistsWeb() {
|
|
51
53
|
return !!pca;
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
authenticateSilently,
|
|
4
4
|
authenticationClientExists,
|
|
5
5
|
initiateAuthenticationClient
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-UGY2AUZX.js";
|
|
7
7
|
import {
|
|
8
8
|
__async
|
|
9
9
|
} from "./chunk-CWMXXUWU.js";
|
|
@@ -22,7 +22,7 @@ var useAuthenticate = ({
|
|
|
22
22
|
);
|
|
23
23
|
const [authenticationInProgress, setAuthenticationInProgress] = useState(false);
|
|
24
24
|
const [authenticationClientInitialized, setAuthenticationClientInitialized] = useState(false);
|
|
25
|
-
const withAuthenticationPromiseHandler = (promise, type) => __async(
|
|
25
|
+
const withAuthenticationPromiseHandler = (promise, type) => __async(null, null, function* () {
|
|
26
26
|
setAuthenticationInProgress(true);
|
|
27
27
|
try {
|
|
28
28
|
const res = yield promise();
|
|
@@ -34,8 +34,8 @@ var useAuthenticate = ({
|
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
36
|
useEffect(() => {
|
|
37
|
-
const initiateClientAndMaybeAuthenticateSilently = () => __async(
|
|
38
|
-
initiateAuthenticationClient(config, discovery);
|
|
37
|
+
const initiateClientAndMaybeAuthenticateSilently = () => __async(null, null, function* () {
|
|
38
|
+
yield initiateAuthenticationClient(config, discovery);
|
|
39
39
|
if (authenticationClientExists()) setAuthenticationClientInitialized(true);
|
|
40
40
|
if (enableAutomaticAuthentication)
|
|
41
41
|
yield withAuthenticationPromiseHandler(
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
LoginButton
|
|
3
|
-
} from "./chunk-UYO5Y6CJ.js";
|
|
4
1
|
import {
|
|
5
2
|
useAccount
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5RSIJ5AN.js";
|
|
4
|
+
import {
|
|
5
|
+
LoginButton
|
|
6
|
+
} from "./chunk-PGRO37AZ.js";
|
|
7
7
|
import {
|
|
8
8
|
useAuthenticate
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-T5YGX52R.js";
|
|
10
10
|
import {
|
|
11
11
|
authenticateInteractively,
|
|
12
12
|
authenticateSilently,
|
|
13
13
|
authenticationClientExists,
|
|
14
14
|
initiateAuthenticationClient,
|
|
15
15
|
signOut
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-UGY2AUZX.js";
|
|
17
17
|
import {
|
|
18
18
|
getAccountWeb
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-LT4NDIEQ.js";
|
|
20
20
|
import {
|
|
21
21
|
getAccount
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-BDLB5HOI.js";
|
|
23
23
|
import {
|
|
24
24
|
getConfig,
|
|
25
25
|
getDiscovery,
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
setToken,
|
|
35
35
|
setUserData,
|
|
36
36
|
useAuth
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-BZJJPLOA.js";
|
|
38
38
|
import {
|
|
39
39
|
__export
|
|
40
40
|
} from "./chunk-CWMXXUWU.js";
|
|
@@ -4,24 +4,29 @@ import {
|
|
|
4
4
|
authenticationClientExistsWeb,
|
|
5
5
|
initiateAuthenticationClientWeb,
|
|
6
6
|
signOutWeb
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LT4NDIEQ.js";
|
|
8
8
|
import {
|
|
9
9
|
authenticateInteractively,
|
|
10
10
|
authenticateSilently,
|
|
11
11
|
authenticationClientExists,
|
|
12
12
|
initiateAuthenticationClient,
|
|
13
13
|
signOut
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-BDLB5HOI.js";
|
|
15
|
+
import {
|
|
16
|
+
__async
|
|
17
|
+
} from "./chunk-CWMXXUWU.js";
|
|
15
18
|
|
|
16
19
|
// src/Expo-AuthSession/authenticationHandler/index.ts
|
|
17
20
|
import { Platform } from "react-native";
|
|
18
21
|
var signOut2 = () => Platform.OS === "web" ? signOutWeb() : signOut();
|
|
19
22
|
var authenticateSilently2 = (scopes) => Platform.OS === "web" ? authenticateSilentlyWeb(scopes) : authenticateSilently();
|
|
20
23
|
var authenticateInteractively2 = (scopes) => Platform.OS === "web" ? authenticateInteractivelyWeb(scopes) : authenticateInteractively();
|
|
21
|
-
var initiateAuthenticationClient2 = (config, discovery) =>
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
+
});
|
|
25
30
|
var authenticationClientExists2 = () => Platform.OS === "web" ? authenticationClientExistsWeb() : authenticationClientExists();
|
|
26
31
|
|
|
27
32
|
export {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getConfig,
|
|
3
3
|
getDiscovery
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BZJJPLOA.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(
|
|
10
|
+
var tokenRefresh = (token) => __async(null, null, function* () {
|
|
11
11
|
const discovery = getDiscovery();
|
|
12
12
|
const config = getConfig();
|
|
13
13
|
if (!discovery || !config) {
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ButtonProps } from "@equinor/mad-components";
|
|
3
|
-
import { AuthenticationType } from "../hooks/useAuthenticate";
|
|
4
|
-
import { MadAuthenticationResult } from "../types";
|
|
5
|
-
export type LoginButtonProps = Omit<ButtonProps, "onPress" | "loading" | "disabled" | "title"> & {
|
|
6
|
-
clientId: string;
|
|
7
|
-
redirectUri: string;
|
|
8
|
-
onAuthenticationSuccessful: (res: MadAuthenticationResult, type: AuthenticationType) => void;
|
|
9
|
-
onAuthenticationFailed: (error: unknown) => void;
|
|
10
|
-
title?: ButtonProps["title"];
|
|
11
|
-
scopes?: string[];
|
|
12
|
-
enableAutomaticAuthentication?: boolean;
|
|
13
|
-
};
|
|
14
|
-
export declare const LoginButton: ({ clientId, redirectUri, onAuthenticationSuccessful, onAuthenticationFailed, enableAutomaticAuthentication, scopes, title, ...rest }: LoginButtonProps) => React.JSX.Element;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./LoginButton";
|
package/dist/components/index.js
CHANGED
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import "../chunk-GUKC6UGZ.js";
|
|
2
|
-
import {
|
|
3
|
-
useAccount
|
|
4
|
-
} from "../chunk-RBOUHIMW.js";
|
|
5
|
-
import {
|
|
6
|
-
useAuthenticate
|
|
7
|
-
} from "../chunk-XENWB4ZX.js";
|
|
8
|
-
import "../chunk-DNMYY37N.js";
|
|
9
|
-
import "../chunk-7SOSXNKP.js";
|
|
10
|
-
import "../chunk-CWMXXUWU.js";
|
|
11
|
-
export {
|
|
12
|
-
useAccount,
|
|
13
|
-
useAuthenticate
|
|
14
|
-
};
|
package/dist/hooks/useAccount.js
CHANGED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { MadAuthenticationResult } from "../types";
|
|
2
|
-
export type UseAuthenticateProps = {
|
|
3
|
-
onAuthenticationSuccessful: (res: MadAuthenticationResult, type: AuthenticationType) => void;
|
|
4
|
-
onAuthenticationFailed: (error: unknown) => void;
|
|
5
|
-
redirectUri: string;
|
|
6
|
-
clientId: string;
|
|
7
|
-
scopes: string[];
|
|
8
|
-
enableAutomaticAuthentication?: boolean;
|
|
9
|
-
};
|
|
10
|
-
export type AuthenticationType = "AUTOMATIC" | "MANUAL";
|
|
11
|
-
type UseAuthenticateResult = {
|
|
12
|
-
authenticate: () => void;
|
|
13
|
-
authenticationInProgress: boolean;
|
|
14
|
-
authenticationClientInitialized: boolean;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* initialize the authentication client, and authenticate the user
|
|
18
|
-
* @param {UseAuthenticateProps} params params for client initialization and authentication flow
|
|
19
|
-
* @returns authenticate function, and some helper variables
|
|
20
|
-
*/
|
|
21
|
-
export declare const useAuthenticate: ({ onAuthenticationSuccessful, onAuthenticationFailed, clientId, redirectUri, scopes, enableAutomaticAuthentication, }: UseAuthenticateProps) => UseAuthenticateResult;
|
|
22
|
-
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
export { authenticateInteractively, authenticateSilently, authenticationClientExists, initiateAuthenticationClient, getAccount, signOut, } from "./auth";
|
|
2
1
|
export * from "./types";
|
|
3
|
-
export * from "./components";
|
|
4
|
-
export * from "./hooks";
|
|
5
2
|
export * as ExpoAuthSession from "./Expo-AuthSession";
|
package/dist/index.js
CHANGED
|
@@ -1,51 +1,23 @@
|
|
|
1
|
-
import "./chunk-GUKC6UGZ.js";
|
|
2
|
-
import {
|
|
3
|
-
useAccount
|
|
4
|
-
} from "./chunk-RBOUHIMW.js";
|
|
5
1
|
import "./chunk-6F4PWJZI.js";
|
|
6
2
|
import {
|
|
7
3
|
Expo_AuthSession_exports
|
|
8
|
-
} from "./chunk-
|
|
9
|
-
import "./chunk-
|
|
10
|
-
import "./chunk-
|
|
11
|
-
import "./chunk-
|
|
12
|
-
import "./chunk-
|
|
13
|
-
import "./chunk-
|
|
14
|
-
import "./chunk-
|
|
15
|
-
import "./chunk-
|
|
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";
|
|
9
|
+
import "./chunk-H623QQTI.js";
|
|
10
|
+
import "./chunk-LT4NDIEQ.js";
|
|
11
|
+
import "./chunk-GRAW2VSL.js";
|
|
16
12
|
import "./chunk-MWXZHQN3.js";
|
|
17
|
-
import "./chunk-
|
|
13
|
+
import "./chunk-BDLB5HOI.js";
|
|
18
14
|
import "./chunk-7NSJ6UAV.js";
|
|
19
|
-
import "./chunk-
|
|
20
|
-
import "./chunk-
|
|
21
|
-
import "./chunk-
|
|
15
|
+
import "./chunk-X2FA4SVJ.js";
|
|
16
|
+
import "./chunk-BZJJPLOA.js";
|
|
17
|
+
import "./chunk-FJEJBJRU.js";
|
|
22
18
|
import "./chunk-NP4GJ5X5.js";
|
|
23
|
-
import "./chunk-HAB34YS7.js";
|
|
24
|
-
import {
|
|
25
|
-
LoginButton
|
|
26
|
-
} from "./chunk-7A7RZF24.js";
|
|
27
|
-
import {
|
|
28
|
-
useAuthenticate
|
|
29
|
-
} from "./chunk-XENWB4ZX.js";
|
|
30
|
-
import {
|
|
31
|
-
authenticateInteractively,
|
|
32
|
-
authenticateSilently,
|
|
33
|
-
authenticationClientExists,
|
|
34
|
-
getAccount,
|
|
35
|
-
initiateAuthenticationClient,
|
|
36
|
-
signOut
|
|
37
|
-
} from "./chunk-DNMYY37N.js";
|
|
38
19
|
import "./chunk-7SOSXNKP.js";
|
|
39
20
|
import "./chunk-CWMXXUWU.js";
|
|
40
21
|
export {
|
|
41
|
-
Expo_AuthSession_exports as ExpoAuthSession
|
|
42
|
-
LoginButton,
|
|
43
|
-
authenticateInteractively,
|
|
44
|
-
authenticateSilently,
|
|
45
|
-
authenticationClientExists,
|
|
46
|
-
getAccount,
|
|
47
|
-
initiateAuthenticationClient,
|
|
48
|
-
signOut,
|
|
49
|
-
useAccount,
|
|
50
|
-
useAuthenticate
|
|
22
|
+
Expo_AuthSession_exports as ExpoAuthSession
|
|
51
23
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/mad-auth",
|
|
3
3
|
"description": "A simple wrapper library for react-native-msal",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Equinor Mobile App Delivery team (MAD)"
|
|
7
7
|
},
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"@types/showdown": "^2.0.0",
|
|
28
28
|
"eslint": "^8.46.0",
|
|
29
29
|
"jest": "^29.7.0",
|
|
30
|
-
"jest-expo": "~
|
|
31
|
-
"react-test-renderer": "
|
|
30
|
+
"jest-expo": "~53.0.9",
|
|
31
|
+
"react-test-renderer": "19.0.0",
|
|
32
32
|
"tsup": "^8.3.5"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
@@ -49,10 +49,9 @@
|
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"expo-auth-session": "~6.0.0",
|
|
51
51
|
"expo-crypto": "~14.0.1",
|
|
52
|
-
"react": "
|
|
53
|
-
"react-dom": "
|
|
54
|
-
"react-native": "~0.
|
|
55
|
-
"react-native-msal": "*"
|
|
52
|
+
"react": "19.0.0",
|
|
53
|
+
"react-dom": "19.0.0",
|
|
54
|
+
"react-native": "~0.79.5"
|
|
56
55
|
},
|
|
57
56
|
"scripts": {
|
|
58
57
|
"build": "tsup-node && echo '\n ⚙️ Generating typescript declarations..' && tsc --project tsconfig.json --emitDeclarationOnly --declaration",
|
package/dist/chunk-7A7RZF24.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
useAuthenticate
|
|
3
|
-
} from "./chunk-XENWB4ZX.js";
|
|
4
|
-
import {
|
|
5
|
-
__objRest,
|
|
6
|
-
__spreadValues
|
|
7
|
-
} from "./chunk-CWMXXUWU.js";
|
|
8
|
-
|
|
9
|
-
// src/components/LoginButton.tsx
|
|
10
|
-
import React from "react";
|
|
11
|
-
import { Button } from "@equinor/mad-components";
|
|
12
|
-
var LoginButton = (_a) => {
|
|
13
|
-
var _b = _a, {
|
|
14
|
-
clientId,
|
|
15
|
-
redirectUri,
|
|
16
|
-
onAuthenticationSuccessful,
|
|
17
|
-
onAuthenticationFailed,
|
|
18
|
-
enableAutomaticAuthentication,
|
|
19
|
-
scopes = [],
|
|
20
|
-
title = "Log in"
|
|
21
|
-
} = _b, rest = __objRest(_b, [
|
|
22
|
-
"clientId",
|
|
23
|
-
"redirectUri",
|
|
24
|
-
"onAuthenticationSuccessful",
|
|
25
|
-
"onAuthenticationFailed",
|
|
26
|
-
"enableAutomaticAuthentication",
|
|
27
|
-
"scopes",
|
|
28
|
-
"title"
|
|
29
|
-
]);
|
|
30
|
-
const { authenticate, authenticationInProgress, authenticationClientInitialized } = useAuthenticate({
|
|
31
|
-
clientId,
|
|
32
|
-
redirectUri,
|
|
33
|
-
onAuthenticationSuccessful,
|
|
34
|
-
onAuthenticationFailed,
|
|
35
|
-
scopes,
|
|
36
|
-
enableAutomaticAuthentication
|
|
37
|
-
});
|
|
38
|
-
const loginButtonIsDisabled = authenticationInProgress || authenticationClientInitialized == false;
|
|
39
|
-
return /* @__PURE__ */ React.createElement(
|
|
40
|
-
Button,
|
|
41
|
-
__spreadValues({
|
|
42
|
-
title,
|
|
43
|
-
onPress: authenticate,
|
|
44
|
-
loading: loginButtonIsDisabled,
|
|
45
|
-
disabled: loginButtonIsDisabled
|
|
46
|
-
}, rest)
|
|
47
|
-
);
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export {
|
|
51
|
-
LoginButton
|
|
52
|
-
};
|
package/dist/chunk-DNMYY37N.js
DELETED
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getMadAccount,
|
|
3
|
-
getMadAuthenticationResult
|
|
4
|
-
} from "./chunk-7SOSXNKP.js";
|
|
5
|
-
import {
|
|
6
|
-
__async
|
|
7
|
-
} from "./chunk-CWMXXUWU.js";
|
|
8
|
-
|
|
9
|
-
// src/auth.ts
|
|
10
|
-
import PublicClientApplication from "react-native-msal";
|
|
11
|
-
var pca = null;
|
|
12
|
-
function _getMsalAccount() {
|
|
13
|
-
return __async(this, null, function* () {
|
|
14
|
-
if (!pca) {
|
|
15
|
-
throw new Error("Unable to authenticate, pca is null");
|
|
16
|
-
}
|
|
17
|
-
const accounts = yield pca.getAccounts();
|
|
18
|
-
if (accounts.length > 0) {
|
|
19
|
-
const account = accounts[0];
|
|
20
|
-
return account;
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
function _getMadAccountFromMSAL() {
|
|
26
|
-
return __async(this, null, function* () {
|
|
27
|
-
const msalAccount = yield _getMsalAccount();
|
|
28
|
-
if (msalAccount) return getMadAccount(msalAccount);
|
|
29
|
-
return null;
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
function initiateAuthenticationClient(_0) {
|
|
33
|
-
return __async(this, arguments, function* ({
|
|
34
|
-
clientId,
|
|
35
|
-
redirectUri,
|
|
36
|
-
authority = "https://login.microsoftonline.com/statoilsrm.onmicrosoft.com/"
|
|
37
|
-
}) {
|
|
38
|
-
if (authenticationClientExists()) return;
|
|
39
|
-
const config = {
|
|
40
|
-
auth: {
|
|
41
|
-
authority,
|
|
42
|
-
clientId,
|
|
43
|
-
redirectUri
|
|
44
|
-
},
|
|
45
|
-
cache: { cacheLocation: "localStorage" }
|
|
46
|
-
};
|
|
47
|
-
pca = new PublicClientApplication(config);
|
|
48
|
-
yield pca.init();
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
function authenticationClientExists() {
|
|
52
|
-
return !!pca;
|
|
53
|
-
}
|
|
54
|
-
function authenticateInteractively(scopes) {
|
|
55
|
-
return __async(this, null, function* () {
|
|
56
|
-
if (!pca) {
|
|
57
|
-
throw new Error("Unable to authenticate, authentication client does not exist");
|
|
58
|
-
}
|
|
59
|
-
const result = yield pca.acquireToken({
|
|
60
|
-
scopes
|
|
61
|
-
});
|
|
62
|
-
if (!result) return null;
|
|
63
|
-
return getMadAuthenticationResult(result);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function getAccount() {
|
|
67
|
-
return __async(this, null, function* () {
|
|
68
|
-
return _getMadAccountFromMSAL();
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
function authenticateSilently(scopes) {
|
|
72
|
-
return __async(this, null, function* () {
|
|
73
|
-
if (!pca) {
|
|
74
|
-
throw new Error("Unable to authenticate, authentication client does not exist");
|
|
75
|
-
}
|
|
76
|
-
const msalAccount = yield _getMsalAccount();
|
|
77
|
-
if (msalAccount) {
|
|
78
|
-
const params = {
|
|
79
|
-
account: msalAccount,
|
|
80
|
-
scopes,
|
|
81
|
-
forceRefresh: false
|
|
82
|
-
};
|
|
83
|
-
const result = yield pca.acquireTokenSilent(params).catch((e) => {
|
|
84
|
-
console.log("Error while fetching token silently", e);
|
|
85
|
-
}).then((res) => res);
|
|
86
|
-
if (!result) return null;
|
|
87
|
-
return getMadAuthenticationResult(result);
|
|
88
|
-
}
|
|
89
|
-
return null;
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
function signOut() {
|
|
93
|
-
return __async(this, null, function* () {
|
|
94
|
-
if (!pca) {
|
|
95
|
-
throw new Error("Unable to authenticate, authentication client does not exist");
|
|
96
|
-
}
|
|
97
|
-
const account = yield _getMsalAccount();
|
|
98
|
-
if (account) {
|
|
99
|
-
const success = yield pca.removeAccount(account);
|
|
100
|
-
return success;
|
|
101
|
-
}
|
|
102
|
-
return false;
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
function _reset() {
|
|
106
|
-
pca = null;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
export {
|
|
110
|
-
initiateAuthenticationClient,
|
|
111
|
-
authenticationClientExists,
|
|
112
|
-
authenticateInteractively,
|
|
113
|
-
getAccount,
|
|
114
|
-
authenticateSilently,
|
|
115
|
-
signOut,
|
|
116
|
-
_reset
|
|
117
|
-
};
|
package/dist/chunk-GUKC6UGZ.js
DELETED
|
File without changes
|
package/dist/chunk-HAB34YS7.js
DELETED
|
File without changes
|
package/dist/chunk-RBOUHIMW.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getAccount
|
|
3
|
-
} from "./chunk-DNMYY37N.js";
|
|
4
|
-
import {
|
|
5
|
-
__async
|
|
6
|
-
} from "./chunk-CWMXXUWU.js";
|
|
7
|
-
|
|
8
|
-
// src/hooks/useAccount.ts
|
|
9
|
-
import { useEffect, useState } from "react";
|
|
10
|
-
var useAccount = () => {
|
|
11
|
-
const [account, setAccount] = useState();
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
const getAndSetAccount = () => __async(void 0, null, function* () {
|
|
14
|
-
try {
|
|
15
|
-
const account2 = yield getAccount();
|
|
16
|
-
setAccount(account2);
|
|
17
|
-
} catch (e) {
|
|
18
|
-
throw new Error("Unable to get account", { cause: e });
|
|
19
|
-
}
|
|
20
|
-
});
|
|
21
|
-
void getAndSetAccount();
|
|
22
|
-
}, []);
|
|
23
|
-
return account;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export {
|
|
27
|
-
useAccount
|
|
28
|
-
};
|
package/dist/chunk-XENWB4ZX.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
authenticateInteractively,
|
|
3
|
-
authenticateSilently,
|
|
4
|
-
authenticationClientExists,
|
|
5
|
-
initiateAuthenticationClient
|
|
6
|
-
} from "./chunk-DNMYY37N.js";
|
|
7
|
-
import {
|
|
8
|
-
__async
|
|
9
|
-
} from "./chunk-CWMXXUWU.js";
|
|
10
|
-
|
|
11
|
-
// src/hooks/useAuthenticate.ts
|
|
12
|
-
import { useEffect, useState } from "react";
|
|
13
|
-
var useAuthenticate = ({
|
|
14
|
-
onAuthenticationSuccessful,
|
|
15
|
-
onAuthenticationFailed,
|
|
16
|
-
clientId,
|
|
17
|
-
redirectUri,
|
|
18
|
-
scopes,
|
|
19
|
-
enableAutomaticAuthentication
|
|
20
|
-
}) => {
|
|
21
|
-
const [authenticationInProgress, setAuthenticationInProgress] = useState(false);
|
|
22
|
-
const [authenticationClientInitialized, setAuthenticationClientInitialized] = useState(false);
|
|
23
|
-
const withAuthenticationPromiseHandler = (promise, type) => __async(void 0, null, function* () {
|
|
24
|
-
setAuthenticationInProgress(true);
|
|
25
|
-
try {
|
|
26
|
-
const res = yield promise;
|
|
27
|
-
if (res) onAuthenticationSuccessful(res, type);
|
|
28
|
-
} catch (e) {
|
|
29
|
-
if (type === "MANUAL") onAuthenticationFailed(e);
|
|
30
|
-
} finally {
|
|
31
|
-
setAuthenticationInProgress(false);
|
|
32
|
-
}
|
|
33
|
-
});
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const initiateClientAndMaybeAuthenticateSilently = () => __async(void 0, null, function* () {
|
|
36
|
-
yield initiateAuthenticationClient({
|
|
37
|
-
clientId,
|
|
38
|
-
redirectUri
|
|
39
|
-
});
|
|
40
|
-
if (authenticationClientExists()) setAuthenticationClientInitialized(true);
|
|
41
|
-
if (enableAutomaticAuthentication)
|
|
42
|
-
void withAuthenticationPromiseHandler(authenticateSilently(scopes), "AUTOMATIC");
|
|
43
|
-
});
|
|
44
|
-
void initiateClientAndMaybeAuthenticateSilently();
|
|
45
|
-
}, []);
|
|
46
|
-
return {
|
|
47
|
-
authenticationInProgress,
|
|
48
|
-
authenticate: () => void withAuthenticationPromiseHandler(authenticateInteractively(scopes), "MANUAL"),
|
|
49
|
-
authenticationClientInitialized: authenticationClientExists() && authenticationClientInitialized
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export {
|
|
54
|
-
useAuthenticate
|
|
55
|
-
};
|