@equinor/mad-auth 0.1.24 → 0.2.1
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 +16 -0
- package/dist/Expo-AuthSession/authenticationHandler/auth.d.ts +32 -0
- package/dist/Expo-AuthSession/authenticationHandler/auth.js +23 -0
- package/dist/Expo-AuthSession/authenticationHandler/index.d.ts +8 -0
- package/dist/Expo-AuthSession/authenticationHandler/index.js +31 -0
- package/dist/Expo-AuthSession/authenticationHandler/web/authWeb.d.ts +39 -0
- package/dist/Expo-AuthSession/authenticationHandler/web/authWeb.js +22 -0
- package/dist/Expo-AuthSession/authenticationHandler/web/index.d.ts +4 -0
- package/dist/Expo-AuthSession/authenticationHandler/web/index.js +33 -0
- package/dist/Expo-AuthSession/authenticationHandler/web/publicClientApplication.d.ts +13 -0
- package/dist/Expo-AuthSession/authenticationHandler/web/publicClientApplication.js +8 -0
- package/dist/Expo-AuthSession/authenticationHandler/web/types.d.ts +304 -0
- package/dist/Expo-AuthSession/authenticationHandler/web/types.js +11 -0
- package/dist/Expo-AuthSession/components/LoginButton.d.ts +4 -0
- package/dist/Expo-AuthSession/components/LoginButton.js +19 -0
- package/dist/Expo-AuthSession/hooks/useAccount.d.ts +2 -0
- package/dist/Expo-AuthSession/hooks/useAccount.js +18 -0
- package/dist/Expo-AuthSession/hooks/useAuthenticate.d.ts +20 -0
- package/dist/Expo-AuthSession/hooks/useAuthenticate.js +18 -0
- package/dist/Expo-AuthSession/index.d.ts +6 -0
- package/dist/Expo-AuthSession/index.js +72 -0
- package/dist/Expo-AuthSession/store/authStore.d.ts +36 -0
- package/dist/Expo-AuthSession/store/authStore.js +32 -0
- package/dist/Expo-AuthSession/store/encryption.d.ts +4 -0
- package/dist/Expo-AuthSession/store/encryption.js +11 -0
- package/dist/Expo-AuthSession/types.d.ts +16 -0
- package/dist/Expo-AuthSession/types.js +1 -0
- package/dist/Expo-AuthSession/utils/decodeToken.d.ts +8 -0
- package/dist/Expo-AuthSession/utils/decodeToken.js +7 -0
- package/dist/Expo-AuthSession/utils/tokenRefresh.d.ts +2 -0
- package/dist/Expo-AuthSession/utils/tokenRefresh.js +9 -0
- package/dist/_internal/translationLayer.d.ts +1 -1
- package/dist/_internal/translationLayer.js +2 -1
- package/dist/auth.d.ts +4 -0
- package/dist/auth.js +5 -2
- package/dist/chunk-2APLN7PB.js +63 -0
- package/dist/chunk-5WASXW2G.js +49 -0
- package/dist/chunk-6Q5OCWP7.js +21 -0
- package/dist/chunk-6UTWP7VI.js +123 -0
- package/dist/{chunk-ZTEWSERJ.js → chunk-7FYKB6SB.js} +2 -2
- package/dist/chunk-7SOSXNKP.js +17 -0
- package/dist/{chunk-HIGCNJNC.js → chunk-AD532AOW.js} +2 -2
- package/dist/chunk-D7L44FRV.js +17 -0
- package/dist/chunk-DXZ4T5LX.js +87 -0
- package/dist/chunk-FF7UDUOZ.js +33 -0
- package/dist/chunk-GCVP36UH.js +10 -0
- package/dist/chunk-MWXZHQN3.js +36 -0
- package/dist/chunk-NP4GJ5X5.js +0 -0
- package/dist/chunk-OFQ6U2BU.js +103 -0
- package/dist/chunk-RJMLROQP.js +37 -0
- package/dist/{chunk-UT6IGOV7.js → chunk-TTVDYDVO.js} +9 -3
- package/dist/{chunk-763B4HQC.js → chunk-WEAGW6MQ.js} +10 -16
- package/dist/chunk-WQQ3TZZU.js +127 -0
- package/dist/{chunk-GCZJ767T.js → chunk-XAS776NQ.js} +2 -2
- package/dist/chunk-XHVESUQ2.js +60 -0
- package/dist/chunk-YFQJZFRR.js +72 -0
- package/dist/components/LoginButton.js +5 -4
- package/dist/components/index.js +5 -4
- package/dist/hooks/index.js +7 -6
- package/dist/hooks/useAccount.js +4 -3
- package/dist/hooks/useAuthenticate.js +4 -3
- package/dist/index.d.ts +2 -1
- package/dist/index.js +27 -8
- package/package.json +66 -46
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import {
|
|
2
|
+
authenticateInteractivelyWeb,
|
|
3
|
+
authenticateSilentlyWeb,
|
|
4
|
+
authenticationClientExistsWeb,
|
|
5
|
+
initiateAuthenticationClientWeb,
|
|
6
|
+
signOutWeb
|
|
7
|
+
} from "./chunk-6UTWP7VI.js";
|
|
8
|
+
import {
|
|
9
|
+
authenticateInteractively,
|
|
10
|
+
authenticateSilently,
|
|
11
|
+
authenticationClientExists,
|
|
12
|
+
initiateAuthenticationClient,
|
|
13
|
+
signOut
|
|
14
|
+
} from "./chunk-OFQ6U2BU.js";
|
|
15
|
+
|
|
16
|
+
// src/Expo-AuthSession/authenticationHandler/index.ts
|
|
17
|
+
import { Platform } from "react-native";
|
|
18
|
+
var signOut2 = () => Platform.OS === "web" ? signOutWeb() : signOut();
|
|
19
|
+
var authenticateSilently2 = (scopes) => Platform.OS === "web" ? authenticateSilentlyWeb(scopes) : authenticateSilently();
|
|
20
|
+
var authenticateInteractively2 = (scopes) => Platform.OS === "web" ? authenticateInteractivelyWeb(scopes) : authenticateInteractively();
|
|
21
|
+
var initiateAuthenticationClient2 = (config, discovery) => Platform.OS === "web" ? initiateAuthenticationClientWeb({
|
|
22
|
+
clientId: config.clientId,
|
|
23
|
+
redirectUri: config.redirectUri
|
|
24
|
+
}) : initiateAuthenticationClient(config, discovery);
|
|
25
|
+
var authenticationClientExists2 = () => Platform.OS === "web" ? authenticationClientExistsWeb() : authenticationClientExists();
|
|
26
|
+
|
|
27
|
+
export {
|
|
28
|
+
signOut2 as signOut,
|
|
29
|
+
authenticateSilently2 as authenticateSilently,
|
|
30
|
+
authenticateInteractively2 as authenticateInteractively,
|
|
31
|
+
initiateAuthenticationClient2 as initiateAuthenticationClient,
|
|
32
|
+
authenticationClientExists2 as authenticationClientExists
|
|
33
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// src/Expo-AuthSession/authenticationHandler/web/types.ts
|
|
2
|
+
var MSALPromptType = /* @__PURE__ */ ((MSALPromptType2) => {
|
|
3
|
+
MSALPromptType2[MSALPromptType2["SELECT_ACCOUNT"] = 0] = "SELECT_ACCOUNT";
|
|
4
|
+
MSALPromptType2[MSALPromptType2["LOGIN"] = 1] = "LOGIN";
|
|
5
|
+
MSALPromptType2[MSALPromptType2["CONSENT"] = 2] = "CONSENT";
|
|
6
|
+
MSALPromptType2[MSALPromptType2["WHEN_REQUIRED"] = 3] = "WHEN_REQUIRED";
|
|
7
|
+
MSALPromptType2[MSALPromptType2["DEFAULT"] = 3 /* WHEN_REQUIRED */] = "DEFAULT";
|
|
8
|
+
return MSALPromptType2;
|
|
9
|
+
})(MSALPromptType || {});
|
|
10
|
+
var Ios_ModalPresentationStyle = /* @__PURE__ */ ((Ios_ModalPresentationStyle2) => {
|
|
11
|
+
Ios_ModalPresentationStyle2[Ios_ModalPresentationStyle2["fullScreen"] = 0] = "fullScreen";
|
|
12
|
+
Ios_ModalPresentationStyle2[Ios_ModalPresentationStyle2["pageSheet"] = 1] = "pageSheet";
|
|
13
|
+
Ios_ModalPresentationStyle2[Ios_ModalPresentationStyle2["formSheet"] = 2] = "formSheet";
|
|
14
|
+
Ios_ModalPresentationStyle2[Ios_ModalPresentationStyle2["currentContext"] = 3] = "currentContext";
|
|
15
|
+
Ios_ModalPresentationStyle2[Ios_ModalPresentationStyle2["custom"] = 4] = "custom";
|
|
16
|
+
Ios_ModalPresentationStyle2[Ios_ModalPresentationStyle2["overFullScreen"] = 5] = "overFullScreen";
|
|
17
|
+
Ios_ModalPresentationStyle2[Ios_ModalPresentationStyle2["overCurrentContext"] = 6] = "overCurrentContext";
|
|
18
|
+
Ios_ModalPresentationStyle2[Ios_ModalPresentationStyle2["popover"] = 7] = "popover";
|
|
19
|
+
Ios_ModalPresentationStyle2[Ios_ModalPresentationStyle2["blurOverFullScreen"] = 8] = "blurOverFullScreen";
|
|
20
|
+
Ios_ModalPresentationStyle2[Ios_ModalPresentationStyle2["none"] = -1] = "none";
|
|
21
|
+
Ios_ModalPresentationStyle2[Ios_ModalPresentationStyle2["automatic"] = -2] = "automatic";
|
|
22
|
+
return Ios_ModalPresentationStyle2;
|
|
23
|
+
})(Ios_ModalPresentationStyle || {});
|
|
24
|
+
var Ios_MSALWebviewType = /* @__PURE__ */ ((Ios_MSALWebviewType2) => {
|
|
25
|
+
Ios_MSALWebviewType2[Ios_MSALWebviewType2["DEFAULT"] = 0] = "DEFAULT";
|
|
26
|
+
Ios_MSALWebviewType2[Ios_MSALWebviewType2["AUTHENTICATION_SESSION"] = 1] = "AUTHENTICATION_SESSION";
|
|
27
|
+
Ios_MSALWebviewType2[Ios_MSALWebviewType2["SAFARI_VIEW_CONTROLLER"] = 2] = "SAFARI_VIEW_CONTROLLER";
|
|
28
|
+
Ios_MSALWebviewType2[Ios_MSALWebviewType2["WK_WEB_VIEW"] = 3] = "WK_WEB_VIEW";
|
|
29
|
+
return Ios_MSALWebviewType2;
|
|
30
|
+
})(Ios_MSALWebviewType || {});
|
|
31
|
+
|
|
32
|
+
export {
|
|
33
|
+
MSALPromptType,
|
|
34
|
+
Ios_ModalPresentationStyle,
|
|
35
|
+
Ios_MSALWebviewType
|
|
36
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import {
|
|
2
|
+
decodeToken
|
|
3
|
+
} from "./chunk-D7L44FRV.js";
|
|
4
|
+
import {
|
|
5
|
+
tokenRefresh
|
|
6
|
+
} from "./chunk-6Q5OCWP7.js";
|
|
7
|
+
import {
|
|
8
|
+
getConfig,
|
|
9
|
+
getDiscovery,
|
|
10
|
+
getToken,
|
|
11
|
+
getUserData,
|
|
12
|
+
resetConfig,
|
|
13
|
+
resetDiscovery,
|
|
14
|
+
resetToken,
|
|
15
|
+
resetUserData,
|
|
16
|
+
setConfig,
|
|
17
|
+
setDiscovery,
|
|
18
|
+
setToken,
|
|
19
|
+
setUserData
|
|
20
|
+
} from "./chunk-DXZ4T5LX.js";
|
|
21
|
+
import {
|
|
22
|
+
__async
|
|
23
|
+
} from "./chunk-WEAGW6MQ.js";
|
|
24
|
+
|
|
25
|
+
// src/Expo-AuthSession/authenticationHandler/auth.ts
|
|
26
|
+
import {
|
|
27
|
+
AuthRequest,
|
|
28
|
+
exchangeCodeAsync,
|
|
29
|
+
TokenResponse
|
|
30
|
+
} from "expo-auth-session";
|
|
31
|
+
import "core-js/stable/atob";
|
|
32
|
+
function initiateAuthenticationClient(config, discovery) {
|
|
33
|
+
setConfig(config);
|
|
34
|
+
setDiscovery(discovery);
|
|
35
|
+
}
|
|
36
|
+
function authenticationClientExists() {
|
|
37
|
+
return !!getConfig() && !!getDiscovery();
|
|
38
|
+
}
|
|
39
|
+
var authenticateInteractively = () => __async(void 0, null, function* () {
|
|
40
|
+
const discovery = getDiscovery();
|
|
41
|
+
const config = getConfig();
|
|
42
|
+
if (!discovery || !config)
|
|
43
|
+
return null;
|
|
44
|
+
const authRequest = new AuthRequest(config);
|
|
45
|
+
const codeResponse = yield authRequest.promptAsync(discovery);
|
|
46
|
+
if ((codeResponse == null ? void 0 : codeResponse.type) === "success") {
|
|
47
|
+
const accessTokenConfig = {
|
|
48
|
+
clientId: config.clientId,
|
|
49
|
+
code: codeResponse.params["code"],
|
|
50
|
+
extraParams: authRequest.codeVerifier ? { code_verifier: authRequest.codeVerifier } : void 0,
|
|
51
|
+
redirectUri: config.redirectUri
|
|
52
|
+
};
|
|
53
|
+
const tokenResponse = yield exchangeCodeAsync(accessTokenConfig, discovery);
|
|
54
|
+
const userData = decodeToken(tokenResponse.accessToken);
|
|
55
|
+
if (!userData)
|
|
56
|
+
return null;
|
|
57
|
+
setUserData(userData);
|
|
58
|
+
setToken(tokenResponse);
|
|
59
|
+
return { account: userData, accessToken: tokenResponse.accessToken };
|
|
60
|
+
}
|
|
61
|
+
return null;
|
|
62
|
+
});
|
|
63
|
+
var authenticateSilently = () => __async(void 0, null, function* () {
|
|
64
|
+
const userData = getUserData();
|
|
65
|
+
const token = getToken();
|
|
66
|
+
if (!userData || !token)
|
|
67
|
+
return null;
|
|
68
|
+
if (TokenResponse.isTokenFresh(token)) {
|
|
69
|
+
return { account: userData, accessToken: token.accessToken };
|
|
70
|
+
}
|
|
71
|
+
const newToken = yield tokenRefresh(token);
|
|
72
|
+
if (newToken) {
|
|
73
|
+
setToken(newToken);
|
|
74
|
+
return { account: userData, accessToken: newToken.accessToken };
|
|
75
|
+
}
|
|
76
|
+
return null;
|
|
77
|
+
});
|
|
78
|
+
function getAccount() {
|
|
79
|
+
var _a;
|
|
80
|
+
return (_a = getUserData()) != null ? _a : null;
|
|
81
|
+
}
|
|
82
|
+
function signOut() {
|
|
83
|
+
if (!authenticationClientExists()) {
|
|
84
|
+
throw new Error("Unable to authenticate, authentication client does not exist");
|
|
85
|
+
}
|
|
86
|
+
resetUserData();
|
|
87
|
+
resetToken();
|
|
88
|
+
return true;
|
|
89
|
+
}
|
|
90
|
+
function reset() {
|
|
91
|
+
resetDiscovery();
|
|
92
|
+
resetConfig();
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export {
|
|
96
|
+
initiateAuthenticationClient,
|
|
97
|
+
authenticationClientExists,
|
|
98
|
+
authenticateInteractively,
|
|
99
|
+
authenticateSilently,
|
|
100
|
+
getAccount,
|
|
101
|
+
signOut,
|
|
102
|
+
reset
|
|
103
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getAccountWeb
|
|
3
|
+
} from "./chunk-6UTWP7VI.js";
|
|
4
|
+
import {
|
|
5
|
+
useAuth
|
|
6
|
+
} from "./chunk-DXZ4T5LX.js";
|
|
7
|
+
import {
|
|
8
|
+
__async
|
|
9
|
+
} from "./chunk-WEAGW6MQ.js";
|
|
10
|
+
|
|
11
|
+
// src/Expo-AuthSession/hooks/useAccount.ts
|
|
12
|
+
import { useEffect, useState } from "react";
|
|
13
|
+
import { Platform } from "react-native";
|
|
14
|
+
var useAccountNative = () => {
|
|
15
|
+
const authState = useAuth();
|
|
16
|
+
return authState.userData;
|
|
17
|
+
};
|
|
18
|
+
var useAccountWeb = () => {
|
|
19
|
+
const [account, setAccount] = useState();
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const getAndSetAccount = () => __async(void 0, null, function* () {
|
|
22
|
+
try {
|
|
23
|
+
const account2 = yield getAccountWeb();
|
|
24
|
+
setAccount(account2);
|
|
25
|
+
} catch (e) {
|
|
26
|
+
throw new Error("Unable to get account", { cause: e });
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
void getAndSetAccount();
|
|
30
|
+
}, []);
|
|
31
|
+
return account;
|
|
32
|
+
};
|
|
33
|
+
var useAccount = Platform.OS === "web" ? useAccountWeb : useAccountNative;
|
|
34
|
+
|
|
35
|
+
export {
|
|
36
|
+
useAccount
|
|
37
|
+
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
__async,
|
|
3
2
|
getMadAccount,
|
|
4
3
|
getMadAuthenticationResult
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-7SOSXNKP.js";
|
|
5
|
+
import {
|
|
6
|
+
__async
|
|
7
|
+
} from "./chunk-WEAGW6MQ.js";
|
|
6
8
|
|
|
7
9
|
// src/auth.ts
|
|
8
10
|
import PublicClientApplication from "react-native-msal";
|
|
@@ -104,6 +106,9 @@ function signOut() {
|
|
|
104
106
|
return false;
|
|
105
107
|
});
|
|
106
108
|
}
|
|
109
|
+
function _reset() {
|
|
110
|
+
pca = null;
|
|
111
|
+
}
|
|
107
112
|
|
|
108
113
|
export {
|
|
109
114
|
initiateAuthenticationClient,
|
|
@@ -111,5 +116,6 @@ export {
|
|
|
111
116
|
authenticateInteractively,
|
|
112
117
|
getAccount,
|
|
113
118
|
authenticateSilently,
|
|
114
|
-
signOut
|
|
119
|
+
signOut,
|
|
120
|
+
_reset
|
|
115
121
|
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
|
|
|
14
16
|
}
|
|
15
17
|
return a;
|
|
16
18
|
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
17
20
|
var __objRest = (source, exclude) => {
|
|
18
21
|
var target = {};
|
|
19
22
|
for (var prop in source)
|
|
@@ -26,6 +29,10 @@ var __objRest = (source, exclude) => {
|
|
|
26
29
|
}
|
|
27
30
|
return target;
|
|
28
31
|
};
|
|
32
|
+
var __export = (target, all) => {
|
|
33
|
+
for (var name in all)
|
|
34
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
35
|
+
};
|
|
29
36
|
var __async = (__this, __arguments, generator) => {
|
|
30
37
|
return new Promise((resolve, reject) => {
|
|
31
38
|
var fulfilled = (value) => {
|
|
@@ -47,23 +54,10 @@ var __async = (__this, __arguments, generator) => {
|
|
|
47
54
|
});
|
|
48
55
|
};
|
|
49
56
|
|
|
50
|
-
// src/_internal/translationLayer.ts
|
|
51
|
-
var getMadAccount = (account) => {
|
|
52
|
-
var _a;
|
|
53
|
-
return {
|
|
54
|
-
username: account.username,
|
|
55
|
-
name: (_a = account.claims) == null ? void 0 : _a.name,
|
|
56
|
-
identifier: account.identifier
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
var getMadAuthenticationResult = (result) => {
|
|
60
|
-
return { account: getMadAccount(result.account), accessToken: result.accessToken };
|
|
61
|
-
};
|
|
62
|
-
|
|
63
57
|
export {
|
|
64
58
|
__spreadValues,
|
|
59
|
+
__spreadProps,
|
|
65
60
|
__objRest,
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
getMadAuthenticationResult
|
|
61
|
+
__export,
|
|
62
|
+
__async
|
|
69
63
|
};
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__async,
|
|
3
|
+
__objRest,
|
|
4
|
+
__spreadProps,
|
|
5
|
+
__spreadValues
|
|
6
|
+
} from "./chunk-WEAGW6MQ.js";
|
|
7
|
+
|
|
8
|
+
// src/Expo-AuthSession/authenticationHandler/web/publicClientApplication.ts
|
|
9
|
+
import { PublicClientApplication as MSALPublicClientApplication } from "@azure/msal-browser";
|
|
10
|
+
var PublicClientApplication = class {
|
|
11
|
+
constructor(config) {
|
|
12
|
+
this.config = config;
|
|
13
|
+
this._pca = new MSALPublicClientApplication(this.config);
|
|
14
|
+
}
|
|
15
|
+
init() {
|
|
16
|
+
return this;
|
|
17
|
+
}
|
|
18
|
+
acquireToken(params) {
|
|
19
|
+
return __async(this, null, function* () {
|
|
20
|
+
const _a = params, { promptType } = _a, paramsWithoutPromptType = __objRest(_a, ["promptType"]);
|
|
21
|
+
const { accessToken, account, expiresOn, idToken, idTokenClaims, scopes, tenantId } = yield this._pca.acquireTokenPopup(
|
|
22
|
+
promptType ? __spreadProps(__spreadValues({}, paramsWithoutPromptType), { prompt: promptTypeToString(promptType) }) : paramsWithoutPromptType
|
|
23
|
+
);
|
|
24
|
+
if (account && expiresOn) {
|
|
25
|
+
return {
|
|
26
|
+
accessToken,
|
|
27
|
+
account: {
|
|
28
|
+
identifier: account.homeAccountId,
|
|
29
|
+
environment: account.environment,
|
|
30
|
+
tenantId: account.tenantId,
|
|
31
|
+
username: account.username,
|
|
32
|
+
claims: idTokenClaims
|
|
33
|
+
},
|
|
34
|
+
expiresOn: expiresOn == null ? void 0 : expiresOn.getTime(),
|
|
35
|
+
idToken,
|
|
36
|
+
scopes,
|
|
37
|
+
tenantId
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
return void 0;
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
acquireTokenSilent(params) {
|
|
44
|
+
return __async(this, null, function* () {
|
|
45
|
+
var _a;
|
|
46
|
+
const { accessToken, account, expiresOn, idToken, idTokenClaims, scopes, tenantId } = yield this._pca.acquireTokenSilent(__spreadProps(__spreadValues({}, params), {
|
|
47
|
+
account: __spreadProps(__spreadValues({}, params.account), {
|
|
48
|
+
homeAccountId: params.account.identifier,
|
|
49
|
+
environment: (_a = params.account.environment) != null ? _a : "",
|
|
50
|
+
localAccountId: ""
|
|
51
|
+
})
|
|
52
|
+
}));
|
|
53
|
+
if (account && expiresOn) {
|
|
54
|
+
const result = {
|
|
55
|
+
accessToken,
|
|
56
|
+
account: {
|
|
57
|
+
identifier: account.homeAccountId,
|
|
58
|
+
environment: account.environment,
|
|
59
|
+
tenantId: account.tenantId,
|
|
60
|
+
username: account.username,
|
|
61
|
+
claims: idTokenClaims
|
|
62
|
+
},
|
|
63
|
+
expiresOn: expiresOn.getTime(),
|
|
64
|
+
idToken,
|
|
65
|
+
scopes,
|
|
66
|
+
tenantId
|
|
67
|
+
};
|
|
68
|
+
return result;
|
|
69
|
+
}
|
|
70
|
+
return void 0;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
getAccounts() {
|
|
74
|
+
const accounts = this._pca.getAllAccounts();
|
|
75
|
+
return Promise.resolve(
|
|
76
|
+
accounts.map((a) => {
|
|
77
|
+
const { homeAccountId: identifier, environment, tenantId, username } = a;
|
|
78
|
+
const account = { identifier, environment, tenantId, username };
|
|
79
|
+
return account;
|
|
80
|
+
})
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
getAccount(accountIdentifier) {
|
|
84
|
+
const account = this._pca.getAccountByHomeId(accountIdentifier);
|
|
85
|
+
if (account == null) {
|
|
86
|
+
return Promise.reject(Error("Account not found"));
|
|
87
|
+
} else {
|
|
88
|
+
const { homeAccountId: identifier, environment, tenantId, username } = account;
|
|
89
|
+
const msalAccount = { identifier, environment, tenantId, username };
|
|
90
|
+
return Promise.resolve(msalAccount);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
removeAccount(account) {
|
|
94
|
+
return __async(this, null, function* () {
|
|
95
|
+
var _a;
|
|
96
|
+
yield this._pca.logoutRedirect({
|
|
97
|
+
account: __spreadProps(__spreadValues({}, account), {
|
|
98
|
+
homeAccountId: account.identifier,
|
|
99
|
+
environment: (_a = account.environment) != null ? _a : "",
|
|
100
|
+
localAccountId: ""
|
|
101
|
+
})
|
|
102
|
+
});
|
|
103
|
+
return true;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
signOut(params) {
|
|
107
|
+
return __async(this, null, function* () {
|
|
108
|
+
return yield this.removeAccount(params.account);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
function promptTypeToString(promptType) {
|
|
113
|
+
switch (promptType) {
|
|
114
|
+
case 0 /* SELECT_ACCOUNT */:
|
|
115
|
+
return "select_account";
|
|
116
|
+
case 1 /* LOGIN */:
|
|
117
|
+
return "login";
|
|
118
|
+
case 2 /* CONSENT */:
|
|
119
|
+
return "consent";
|
|
120
|
+
case 3 /* WHEN_REQUIRED */:
|
|
121
|
+
return "none";
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export {
|
|
126
|
+
PublicClientApplication
|
|
127
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useAuthenticate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-AD532AOW.js";
|
|
4
4
|
import {
|
|
5
5
|
__objRest,
|
|
6
6
|
__spreadValues
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-WEAGW6MQ.js";
|
|
8
8
|
|
|
9
9
|
// src/components/LoginButton.tsx
|
|
10
10
|
import React from "react";
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import {
|
|
2
|
+
useAuthenticate
|
|
3
|
+
} from "./chunk-2APLN7PB.js";
|
|
4
|
+
import {
|
|
5
|
+
__objRest,
|
|
6
|
+
__spreadValues
|
|
7
|
+
} from "./chunk-WEAGW6MQ.js";
|
|
8
|
+
|
|
9
|
+
// src/Expo-AuthSession/components/LoginButton.tsx
|
|
10
|
+
import React from "react";
|
|
11
|
+
import { Button } from "@equinor/mad-components";
|
|
12
|
+
import * as WebBrowser from "expo-web-browser";
|
|
13
|
+
import { ResponseType } from "expo-auth-session";
|
|
14
|
+
import "core-js/stable/atob";
|
|
15
|
+
import { View } from "react-native";
|
|
16
|
+
WebBrowser.maybeCompleteAuthSession();
|
|
17
|
+
var LoginButton = (_a) => {
|
|
18
|
+
var _b = _a, {
|
|
19
|
+
clientId,
|
|
20
|
+
redirectUri,
|
|
21
|
+
onAuthenticationSuccessful,
|
|
22
|
+
onAuthenticationFailed,
|
|
23
|
+
enableAutomaticAuthentication,
|
|
24
|
+
scopes = [],
|
|
25
|
+
title = "Log in"
|
|
26
|
+
} = _b, rest = __objRest(_b, [
|
|
27
|
+
"clientId",
|
|
28
|
+
"redirectUri",
|
|
29
|
+
"onAuthenticationSuccessful",
|
|
30
|
+
"onAuthenticationFailed",
|
|
31
|
+
"enableAutomaticAuthentication",
|
|
32
|
+
"scopes",
|
|
33
|
+
"title"
|
|
34
|
+
]);
|
|
35
|
+
const config = {
|
|
36
|
+
clientId,
|
|
37
|
+
scopes: [...scopes, "openid", "profile", "offline_access"],
|
|
38
|
+
redirectUri,
|
|
39
|
+
responseType: ResponseType.Code
|
|
40
|
+
};
|
|
41
|
+
const { authenticate, authenticationInProgress } = useAuthenticate({
|
|
42
|
+
config,
|
|
43
|
+
onAuthenticationSuccessful,
|
|
44
|
+
onAuthenticationFailed,
|
|
45
|
+
enableAutomaticAuthentication
|
|
46
|
+
});
|
|
47
|
+
return /* @__PURE__ */ React.createElement(View, null, /* @__PURE__ */ React.createElement(
|
|
48
|
+
Button,
|
|
49
|
+
__spreadValues({
|
|
50
|
+
title,
|
|
51
|
+
onPress: authenticate,
|
|
52
|
+
loading: authenticationInProgress,
|
|
53
|
+
disabled: authenticationInProgress
|
|
54
|
+
}, rest)
|
|
55
|
+
));
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export {
|
|
59
|
+
LoginButton
|
|
60
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LoginButton
|
|
3
|
+
} from "./chunk-XHVESUQ2.js";
|
|
4
|
+
import {
|
|
5
|
+
useAccount
|
|
6
|
+
} from "./chunk-RJMLROQP.js";
|
|
7
|
+
import {
|
|
8
|
+
useAuthenticate
|
|
9
|
+
} from "./chunk-2APLN7PB.js";
|
|
10
|
+
import {
|
|
11
|
+
authenticateInteractively,
|
|
12
|
+
authenticateSilently,
|
|
13
|
+
authenticationClientExists,
|
|
14
|
+
initiateAuthenticationClient,
|
|
15
|
+
signOut
|
|
16
|
+
} from "./chunk-FF7UDUOZ.js";
|
|
17
|
+
import {
|
|
18
|
+
getAccountWeb
|
|
19
|
+
} from "./chunk-6UTWP7VI.js";
|
|
20
|
+
import {
|
|
21
|
+
getAccount
|
|
22
|
+
} from "./chunk-OFQ6U2BU.js";
|
|
23
|
+
import {
|
|
24
|
+
getConfig,
|
|
25
|
+
getDiscovery,
|
|
26
|
+
getToken,
|
|
27
|
+
getUserData,
|
|
28
|
+
resetConfig,
|
|
29
|
+
resetDiscovery,
|
|
30
|
+
resetToken,
|
|
31
|
+
resetUserData,
|
|
32
|
+
setConfig,
|
|
33
|
+
setDiscovery,
|
|
34
|
+
setToken,
|
|
35
|
+
setUserData,
|
|
36
|
+
useAuth
|
|
37
|
+
} from "./chunk-DXZ4T5LX.js";
|
|
38
|
+
import {
|
|
39
|
+
__export
|
|
40
|
+
} from "./chunk-WEAGW6MQ.js";
|
|
41
|
+
|
|
42
|
+
// src/Expo-AuthSession/index.ts
|
|
43
|
+
var Expo_AuthSession_exports = {};
|
|
44
|
+
__export(Expo_AuthSession_exports, {
|
|
45
|
+
LoginButton: () => LoginButton,
|
|
46
|
+
authenticateInteractively: () => authenticateInteractively,
|
|
47
|
+
authenticateSilently: () => authenticateSilently,
|
|
48
|
+
authenticationClientExists: () => authenticationClientExists,
|
|
49
|
+
getAccount: () => getAccount,
|
|
50
|
+
getAccountWeb: () => getAccountWeb,
|
|
51
|
+
getConfig: () => getConfig,
|
|
52
|
+
getDiscovery: () => getDiscovery,
|
|
53
|
+
getToken: () => getToken,
|
|
54
|
+
getUserData: () => getUserData,
|
|
55
|
+
initiateAuthenticationClient: () => initiateAuthenticationClient,
|
|
56
|
+
resetConfig: () => resetConfig,
|
|
57
|
+
resetDiscovery: () => resetDiscovery,
|
|
58
|
+
resetToken: () => resetToken,
|
|
59
|
+
resetUserData: () => resetUserData,
|
|
60
|
+
setConfig: () => setConfig,
|
|
61
|
+
setDiscovery: () => setDiscovery,
|
|
62
|
+
setToken: () => setToken,
|
|
63
|
+
setUserData: () => setUserData,
|
|
64
|
+
signOut: () => signOut,
|
|
65
|
+
useAccount: () => useAccount,
|
|
66
|
+
useAuth: () => useAuth,
|
|
67
|
+
useAuthenticate: () => useAuthenticate
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export {
|
|
71
|
+
Expo_AuthSession_exports
|
|
72
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
LoginButton
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
6
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-XAS776NQ.js";
|
|
4
|
+
import "../chunk-AD532AOW.js";
|
|
5
|
+
import "../chunk-TTVDYDVO.js";
|
|
6
|
+
import "../chunk-7SOSXNKP.js";
|
|
7
|
+
import "../chunk-WEAGW6MQ.js";
|
|
7
8
|
export {
|
|
8
9
|
LoginButton
|
|
9
10
|
};
|
package/dist/components/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
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-XAS776NQ.js";
|
|
5
|
+
import "../chunk-AD532AOW.js";
|
|
6
|
+
import "../chunk-TTVDYDVO.js";
|
|
7
|
+
import "../chunk-7SOSXNKP.js";
|
|
8
|
+
import "../chunk-WEAGW6MQ.js";
|
|
8
9
|
export {
|
|
9
10
|
LoginButton
|
|
10
11
|
};
|
package/dist/hooks/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import "../chunk-GUKC6UGZ.js";
|
|
2
|
-
import {
|
|
3
|
-
useAuthenticate
|
|
4
|
-
} from "../chunk-HIGCNJNC.js";
|
|
5
2
|
import {
|
|
6
3
|
useAccount
|
|
7
|
-
} from "../chunk-
|
|
8
|
-
import
|
|
9
|
-
|
|
4
|
+
} from "../chunk-7FYKB6SB.js";
|
|
5
|
+
import {
|
|
6
|
+
useAuthenticate
|
|
7
|
+
} from "../chunk-AD532AOW.js";
|
|
8
|
+
import "../chunk-TTVDYDVO.js";
|
|
9
|
+
import "../chunk-7SOSXNKP.js";
|
|
10
|
+
import "../chunk-WEAGW6MQ.js";
|
|
10
11
|
export {
|
|
11
12
|
useAccount,
|
|
12
13
|
useAuthenticate
|
package/dist/hooks/useAccount.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useAccount
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-7FYKB6SB.js";
|
|
4
|
+
import "../chunk-TTVDYDVO.js";
|
|
5
|
+
import "../chunk-7SOSXNKP.js";
|
|
6
|
+
import "../chunk-WEAGW6MQ.js";
|
|
6
7
|
export {
|
|
7
8
|
useAccount
|
|
8
9
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
useAuthenticate
|
|
3
|
-
} from "../chunk-
|
|
4
|
-
import "../chunk-
|
|
5
|
-
import "../chunk-
|
|
3
|
+
} from "../chunk-AD532AOW.js";
|
|
4
|
+
import "../chunk-TTVDYDVO.js";
|
|
5
|
+
import "../chunk-7SOSXNKP.js";
|
|
6
|
+
import "../chunk-WEAGW6MQ.js";
|
|
6
7
|
export {
|
|
7
8
|
useAuthenticate
|
|
8
9
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { authenticateInteractively, authenticateSilently, authenticationClientExists, initiateAuthenticationClient, getAccount, signOut, } from "./auth";
|
|
2
2
|
export * from "./types";
|
|
3
3
|
export * from "./components";
|
|
4
4
|
export * from "./hooks";
|
|
5
|
+
export * as ExpoAuthSession from "./Expo-AuthSession";
|