@equinor/mad-auth 0.0.13 → 0.1.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 +27 -0
- package/README.md +1 -0
- package/dist/_internal/translationLayer.js +1 -1
- package/dist/auth.js +2 -2
- package/dist/{chunk-CKRPOC3H.js → chunk-5TNEJPZM.js} +11 -7
- package/dist/{chunk-O262MRUN.js → chunk-6XZQ7DKI.js} +5 -2
- package/dist/{chunk-YGQY3H47.js → chunk-GJN2PRS3.js} +3 -3
- package/dist/{chunk-GZV7V4EL.js → chunk-NRXJJLOK.js} +1 -1
- package/dist/components/LoginButton.d.ts +5 -2
- package/dist/components/LoginButton.js +4 -4
- package/dist/components/index.js +4 -4
- package/dist/hooks/index.js +4 -4
- package/dist/hooks/useAccount.js +3 -3
- package/dist/hooks/useAuthenticate.d.ts +4 -2
- package/dist/hooks/useAuthenticate.js +3 -3
- package/dist/index.js +5 -5
- package/package.json +9 -8
- /package/dist/{chunk-GJUHWXAK.js → chunk-6GAWEDT7.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,32 @@
|
|
|
1
1
|
# @equinor/mad-auth
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 936e5e0: `onAuthenticationSuccessful` now has type as second argument. added
|
|
8
|
+
`onAuthenticationFailed` prop
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [38e818d]
|
|
13
|
+
- Updated dependencies [cf131da]
|
|
14
|
+
- Updated dependencies [e941e2e]
|
|
15
|
+
- @equinor/mad-components@0.8.2
|
|
16
|
+
|
|
17
|
+
## 0.0.14
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies [c8d9131]
|
|
22
|
+
- Updated dependencies [a22023e]
|
|
23
|
+
- Updated dependencies [a57a362]
|
|
24
|
+
- Updated dependencies [a22023e]
|
|
25
|
+
- Updated dependencies [a0999d4]
|
|
26
|
+
- Updated dependencies [bda6748]
|
|
27
|
+
- Updated dependencies [08eeb85]
|
|
28
|
+
- @equinor/mad-components@0.8.1
|
|
29
|
+
|
|
3
30
|
## 0.0.13
|
|
4
31
|
|
|
5
32
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -44,6 +44,7 @@ export const LoginScreen = () => {
|
|
|
44
44
|
redirectUri="msauth.com.equinor.mad.chronicles://auth"
|
|
45
45
|
clientId="49222fe1-4e0a-4310-9e81-1a2c3eb9b2ed"
|
|
46
46
|
onAuthenticationSuccessful={() => navigation.navigate("Root")}
|
|
47
|
+
onAuthenticationFailed={() => console.error("Unable to authenticate")}
|
|
47
48
|
enableAutomaticAuthentication
|
|
48
49
|
/>
|
|
49
50
|
</View>
|
package/dist/auth.js
CHANGED
|
@@ -3,15 +3,16 @@ import {
|
|
|
3
3
|
authenticateSilently,
|
|
4
4
|
authenticationClientExists,
|
|
5
5
|
initiateAuthenticationClient
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-NRXJJLOK.js";
|
|
7
7
|
import {
|
|
8
8
|
__async
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-6GAWEDT7.js";
|
|
10
10
|
|
|
11
11
|
// src/hooks/useAuthenticate.ts
|
|
12
12
|
import { useEffect, useState } from "react";
|
|
13
13
|
var useAuthenticate = ({
|
|
14
14
|
onAuthenticationSuccessful,
|
|
15
|
+
onAuthenticationFailed,
|
|
15
16
|
clientId,
|
|
16
17
|
redirectUri,
|
|
17
18
|
scopes,
|
|
@@ -19,12 +20,15 @@ var useAuthenticate = ({
|
|
|
19
20
|
}) => {
|
|
20
21
|
const [authenticationInProgress, setAuthenticationInProgress] = useState(false);
|
|
21
22
|
const [authenticationClientInitialized, setAuthenticationClientInitialized] = useState(false);
|
|
22
|
-
const withAuthenticationPromiseHandler = (promise) => __async(void 0, null, function* () {
|
|
23
|
+
const withAuthenticationPromiseHandler = (promise, type) => __async(void 0, null, function* () {
|
|
23
24
|
setAuthenticationInProgress(true);
|
|
24
25
|
try {
|
|
25
26
|
const res = yield promise;
|
|
26
27
|
if (res)
|
|
27
|
-
onAuthenticationSuccessful(res);
|
|
28
|
+
onAuthenticationSuccessful(res, type);
|
|
29
|
+
} catch (e) {
|
|
30
|
+
if (type === "MANUAL")
|
|
31
|
+
onAuthenticationFailed(e);
|
|
28
32
|
} finally {
|
|
29
33
|
setAuthenticationInProgress(false);
|
|
30
34
|
}
|
|
@@ -38,13 +42,13 @@ var useAuthenticate = ({
|
|
|
38
42
|
if (authenticationClientExists())
|
|
39
43
|
setAuthenticationClientInitialized(true);
|
|
40
44
|
if (enableAutomaticAuthentication)
|
|
41
|
-
withAuthenticationPromiseHandler(authenticateSilently(scopes));
|
|
45
|
+
void withAuthenticationPromiseHandler(authenticateSilently(scopes), "AUTOMATIC");
|
|
42
46
|
});
|
|
43
|
-
initiateClientAndMaybeAuthenticateSilently();
|
|
47
|
+
void initiateClientAndMaybeAuthenticateSilently();
|
|
44
48
|
}, []);
|
|
45
49
|
return {
|
|
46
50
|
authenticationInProgress,
|
|
47
|
-
authenticate: () => withAuthenticationPromiseHandler(authenticateInteractively(scopes)),
|
|
51
|
+
authenticate: () => void withAuthenticationPromiseHandler(authenticateInteractively(scopes), "MANUAL"),
|
|
48
52
|
authenticationClientInitialized: authenticationClientExists() && authenticationClientInitialized
|
|
49
53
|
};
|
|
50
54
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useAuthenticate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-5TNEJPZM.js";
|
|
4
4
|
import {
|
|
5
5
|
__objRest,
|
|
6
6
|
__spreadValues
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-6GAWEDT7.js";
|
|
8
8
|
|
|
9
9
|
// src/components/LoginButton.tsx
|
|
10
10
|
import React from "react";
|
|
@@ -14,6 +14,7 @@ var LoginButton = (_a) => {
|
|
|
14
14
|
clientId,
|
|
15
15
|
redirectUri,
|
|
16
16
|
onAuthenticationSuccessful,
|
|
17
|
+
onAuthenticationFailed,
|
|
17
18
|
enableAutomaticAuthentication,
|
|
18
19
|
scopes = [],
|
|
19
20
|
title = "Log in"
|
|
@@ -21,6 +22,7 @@ var LoginButton = (_a) => {
|
|
|
21
22
|
"clientId",
|
|
22
23
|
"redirectUri",
|
|
23
24
|
"onAuthenticationSuccessful",
|
|
25
|
+
"onAuthenticationFailed",
|
|
24
26
|
"enableAutomaticAuthentication",
|
|
25
27
|
"scopes",
|
|
26
28
|
"title"
|
|
@@ -29,6 +31,7 @@ var LoginButton = (_a) => {
|
|
|
29
31
|
clientId,
|
|
30
32
|
redirectUri,
|
|
31
33
|
onAuthenticationSuccessful,
|
|
34
|
+
onAuthenticationFailed,
|
|
32
35
|
scopes,
|
|
33
36
|
enableAutomaticAuthentication
|
|
34
37
|
});
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getAccount
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-NRXJJLOK.js";
|
|
4
4
|
import {
|
|
5
5
|
__async
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-6GAWEDT7.js";
|
|
7
7
|
|
|
8
8
|
// src/hooks/useAccount.ts
|
|
9
9
|
import { useEffect, useState } from "react";
|
|
@@ -18,7 +18,7 @@ var useAccount = () => {
|
|
|
18
18
|
throw new Error("Unable to get account", { cause: e });
|
|
19
19
|
}
|
|
20
20
|
});
|
|
21
|
-
getAndSetAccount();
|
|
21
|
+
void getAndSetAccount();
|
|
22
22
|
}, []);
|
|
23
23
|
return account;
|
|
24
24
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { ButtonProps } from "@equinor/mad-components";
|
|
3
|
+
import { AuthenticationType } from "../hooks/useAuthenticate";
|
|
4
|
+
import { MadAuthenticationResult } from "../types";
|
|
3
5
|
export type LoginButtonProps = Omit<ButtonProps, "onPress" | "loading" | "disabled" | "title"> & {
|
|
4
6
|
clientId: string;
|
|
5
7
|
redirectUri: string;
|
|
6
|
-
onAuthenticationSuccessful: () => void;
|
|
8
|
+
onAuthenticationSuccessful: (res: MadAuthenticationResult, type: AuthenticationType) => void;
|
|
9
|
+
onAuthenticationFailed: (error: unknown) => void;
|
|
7
10
|
title?: ButtonProps["title"];
|
|
8
11
|
scopes?: string[];
|
|
9
12
|
enableAutomaticAuthentication?: boolean;
|
|
10
13
|
};
|
|
11
|
-
export declare const LoginButton: ({ clientId, redirectUri, onAuthenticationSuccessful, enableAutomaticAuthentication, scopes, title, ...rest }: LoginButtonProps) => React.JSX.Element;
|
|
14
|
+
export declare const LoginButton: ({ clientId, redirectUri, onAuthenticationSuccessful, onAuthenticationFailed, enableAutomaticAuthentication, scopes, title, ...rest }: LoginButtonProps) => React.JSX.Element;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LoginButton
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-6XZQ7DKI.js";
|
|
4
|
+
import "../chunk-5TNEJPZM.js";
|
|
5
|
+
import "../chunk-NRXJJLOK.js";
|
|
6
|
+
import "../chunk-6GAWEDT7.js";
|
|
7
7
|
export {
|
|
8
8
|
LoginButton
|
|
9
9
|
};
|
package/dist/components/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "../chunk-HAB34YS7.js";
|
|
2
2
|
import {
|
|
3
3
|
LoginButton
|
|
4
|
-
} from "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
7
|
-
import "../chunk-
|
|
4
|
+
} from "../chunk-6XZQ7DKI.js";
|
|
5
|
+
import "../chunk-5TNEJPZM.js";
|
|
6
|
+
import "../chunk-NRXJJLOK.js";
|
|
7
|
+
import "../chunk-6GAWEDT7.js";
|
|
8
8
|
export {
|
|
9
9
|
LoginButton
|
|
10
10
|
};
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import "../chunk-GUKC6UGZ.js";
|
|
2
2
|
import {
|
|
3
3
|
useAuthenticate
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-5TNEJPZM.js";
|
|
5
5
|
import {
|
|
6
6
|
useAccount
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import "../chunk-
|
|
9
|
-
import "../chunk-
|
|
7
|
+
} from "../chunk-GJN2PRS3.js";
|
|
8
|
+
import "../chunk-NRXJJLOK.js";
|
|
9
|
+
import "../chunk-6GAWEDT7.js";
|
|
10
10
|
export {
|
|
11
11
|
useAccount,
|
|
12
12
|
useAuthenticate
|
package/dist/hooks/useAccount.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { MadAuthenticationResult } from "../types";
|
|
2
2
|
export type UseAuthenticateProps = {
|
|
3
|
-
onAuthenticationSuccessful: (res: MadAuthenticationResult) => void;
|
|
3
|
+
onAuthenticationSuccessful: (res: MadAuthenticationResult, type: AuthenticationType) => void;
|
|
4
|
+
onAuthenticationFailed: (error: unknown) => void;
|
|
4
5
|
redirectUri: string;
|
|
5
6
|
clientId: string;
|
|
6
7
|
scopes: string[];
|
|
7
8
|
enableAutomaticAuthentication?: boolean;
|
|
8
9
|
};
|
|
10
|
+
export type AuthenticationType = "AUTOMATIC" | "MANUAL";
|
|
9
11
|
type UseAuthenticateResult = {
|
|
10
12
|
authenticate: () => void;
|
|
11
13
|
authenticationInProgress: boolean;
|
|
@@ -16,5 +18,5 @@ type UseAuthenticateResult = {
|
|
|
16
18
|
* @param {UseAuthenticateProps} params params for client initialization and authentication flow
|
|
17
19
|
* @returns authenticate function, and some helper variables
|
|
18
20
|
*/
|
|
19
|
-
export declare const useAuthenticate: ({ onAuthenticationSuccessful, clientId, redirectUri, scopes, enableAutomaticAuthentication, }: UseAuthenticateProps) => UseAuthenticateResult;
|
|
21
|
+
export declare const useAuthenticate: ({ onAuthenticationSuccessful, onAuthenticationFailed, clientId, redirectUri, scopes, enableAutomaticAuthentication, }: UseAuthenticateProps) => UseAuthenticateResult;
|
|
20
22
|
export {};
|
package/dist/index.js
CHANGED
|
@@ -2,14 +2,14 @@ import "./chunk-6F4PWJZI.js";
|
|
|
2
2
|
import "./chunk-HAB34YS7.js";
|
|
3
3
|
import {
|
|
4
4
|
LoginButton
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-6XZQ7DKI.js";
|
|
6
6
|
import "./chunk-GUKC6UGZ.js";
|
|
7
7
|
import {
|
|
8
8
|
useAuthenticate
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-5TNEJPZM.js";
|
|
10
10
|
import {
|
|
11
11
|
useAccount
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-GJN2PRS3.js";
|
|
13
13
|
import {
|
|
14
14
|
authenticateInteractively,
|
|
15
15
|
authenticateSilently,
|
|
@@ -17,8 +17,8 @@ import {
|
|
|
17
17
|
getAccount,
|
|
18
18
|
initiateAuthenticationClient,
|
|
19
19
|
signOut
|
|
20
|
-
} from "./chunk-
|
|
21
|
-
import "./chunk-
|
|
20
|
+
} from "./chunk-NRXJJLOK.js";
|
|
21
|
+
import "./chunk-6GAWEDT7.js";
|
|
22
22
|
export {
|
|
23
23
|
LoginButton,
|
|
24
24
|
authenticateInteractively,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@equinor/mad-auth",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "A simple wrapper library for react-native-msal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -20,16 +20,16 @@
|
|
|
20
20
|
"main": "./dist/index.js",
|
|
21
21
|
"types": "./dist/index.d.ts",
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"react": ">=
|
|
24
|
-
"react-dom": ">=
|
|
25
|
-
"react-native": ">=0.
|
|
26
|
-
"react-native-msal": "
|
|
23
|
+
"react": ">=18.0",
|
|
24
|
+
"react-dom": ">=18.0",
|
|
25
|
+
"react-native": ">=0.70",
|
|
26
|
+
"react-native-msal": "*"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@equinor/mad-components": "0.8.
|
|
29
|
+
"@equinor/mad-components": "0.8.2"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@equinor/eslint-config-mad": "0.
|
|
32
|
+
"@equinor/eslint-config-mad": "0.3.0"
|
|
33
33
|
},
|
|
34
34
|
"files": [
|
|
35
35
|
"CODE_OF_CONDUCT.md",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"build": "tsup-node && echo '\n ⚙️ Generating typescript declarations..' && tsc --project tsconfig.json --emitDeclarationOnly --declaration",
|
|
42
42
|
"test": "jest",
|
|
43
43
|
"dev": "tsup-node --watch --clean=false",
|
|
44
|
-
"lint": "eslint src/"
|
|
44
|
+
"lint": "eslint src/",
|
|
45
|
+
"clean": "rm -rf node_modules/ && rm -rf dist/"
|
|
45
46
|
}
|
|
46
47
|
}
|
|
File without changes
|