@equinor/mad-auth 0.1.24 → 0.2.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 +10 -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 +4 -0
- package/dist/Expo-AuthSession/hooks/useAccount.js +22 -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 +76 -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-CFM3MLGB.js +39 -0
- 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-JVCNKTCD.js +76 -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-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/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 +65 -46
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getItem,
|
|
3
|
+
removeItem,
|
|
4
|
+
setItem
|
|
5
|
+
} from "./chunk-5WASXW2G.js";
|
|
6
|
+
|
|
7
|
+
// src/Expo-AuthSession/store/authStore.ts
|
|
8
|
+
import { TokenResponse } from "expo-auth-session";
|
|
9
|
+
import { create } from "zustand";
|
|
10
|
+
import { createJSONStorage, devtools, persist } from "zustand/middleware";
|
|
11
|
+
var useAuth = create()(
|
|
12
|
+
devtools(
|
|
13
|
+
persist(
|
|
14
|
+
(set) => ({
|
|
15
|
+
setToken: (token) => {
|
|
16
|
+
set({ token });
|
|
17
|
+
},
|
|
18
|
+
setUserData: (account) => {
|
|
19
|
+
set({ userData: account });
|
|
20
|
+
},
|
|
21
|
+
setDiscovery: (discovery) => {
|
|
22
|
+
set({ discovery });
|
|
23
|
+
},
|
|
24
|
+
setConfig: (config) => {
|
|
25
|
+
set({ config });
|
|
26
|
+
},
|
|
27
|
+
resetToken: () => {
|
|
28
|
+
set({ token: void 0 });
|
|
29
|
+
},
|
|
30
|
+
resetUserData: () => {
|
|
31
|
+
set({ userData: void 0 });
|
|
32
|
+
},
|
|
33
|
+
resetDiscovery: () => {
|
|
34
|
+
set({ discovery: void 0 });
|
|
35
|
+
},
|
|
36
|
+
resetConfig: () => {
|
|
37
|
+
set({ config: void 0 });
|
|
38
|
+
}
|
|
39
|
+
}),
|
|
40
|
+
{
|
|
41
|
+
partialize: (state) => Object.fromEntries(
|
|
42
|
+
Object.entries(state).filter(
|
|
43
|
+
([key]) => ["token", "userData"].includes(key)
|
|
44
|
+
)
|
|
45
|
+
),
|
|
46
|
+
name: "storage",
|
|
47
|
+
storage: createJSONStorage(() => ({
|
|
48
|
+
getItem,
|
|
49
|
+
setItem,
|
|
50
|
+
removeItem
|
|
51
|
+
}))
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
{ name: "core/auth" }
|
|
55
|
+
)
|
|
56
|
+
);
|
|
57
|
+
var getToken = () => {
|
|
58
|
+
const tokenConfig = useAuth.getState().token;
|
|
59
|
+
return tokenConfig ? new TokenResponse(tokenConfig) : void 0;
|
|
60
|
+
};
|
|
61
|
+
var getUserData = () => useAuth.getState().userData;
|
|
62
|
+
var getDiscovery = () => useAuth.getState().discovery;
|
|
63
|
+
var getConfig = () => useAuth.getState().config;
|
|
64
|
+
var setToken = (token) => useAuth.getState().setToken(token);
|
|
65
|
+
var setUserData = (userData) => useAuth.getState().setUserData(userData);
|
|
66
|
+
var setDiscovery = (discovery) => useAuth.getState().setDiscovery(discovery);
|
|
67
|
+
var setConfig = (config) => useAuth.getState().setConfig(config);
|
|
68
|
+
var resetToken = () => useAuth.getState().resetToken();
|
|
69
|
+
var resetUserData = () => useAuth.getState().resetUserData();
|
|
70
|
+
var resetDiscovery = () => useAuth.getState().resetDiscovery();
|
|
71
|
+
var resetConfig = () => useAuth.getState().resetConfig();
|
|
72
|
+
|
|
73
|
+
export {
|
|
74
|
+
useAuth,
|
|
75
|
+
getToken,
|
|
76
|
+
getUserData,
|
|
77
|
+
getDiscovery,
|
|
78
|
+
getConfig,
|
|
79
|
+
setToken,
|
|
80
|
+
setUserData,
|
|
81
|
+
setDiscovery,
|
|
82
|
+
setConfig,
|
|
83
|
+
resetToken,
|
|
84
|
+
resetUserData,
|
|
85
|
+
resetDiscovery,
|
|
86
|
+
resetConfig
|
|
87
|
+
};
|
|
@@ -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,76 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LoginButton
|
|
3
|
+
} from "./chunk-XHVESUQ2.js";
|
|
4
|
+
import {
|
|
5
|
+
useAccount,
|
|
6
|
+
useAccountNative,
|
|
7
|
+
useAccountWeb
|
|
8
|
+
} from "./chunk-CFM3MLGB.js";
|
|
9
|
+
import {
|
|
10
|
+
useAuthenticate
|
|
11
|
+
} from "./chunk-2APLN7PB.js";
|
|
12
|
+
import {
|
|
13
|
+
authenticateInteractively,
|
|
14
|
+
authenticateSilently,
|
|
15
|
+
authenticationClientExists,
|
|
16
|
+
initiateAuthenticationClient,
|
|
17
|
+
signOut
|
|
18
|
+
} from "./chunk-FF7UDUOZ.js";
|
|
19
|
+
import {
|
|
20
|
+
getAccountWeb
|
|
21
|
+
} from "./chunk-6UTWP7VI.js";
|
|
22
|
+
import {
|
|
23
|
+
getAccount
|
|
24
|
+
} from "./chunk-OFQ6U2BU.js";
|
|
25
|
+
import {
|
|
26
|
+
getConfig,
|
|
27
|
+
getDiscovery,
|
|
28
|
+
getToken,
|
|
29
|
+
getUserData,
|
|
30
|
+
resetConfig,
|
|
31
|
+
resetDiscovery,
|
|
32
|
+
resetToken,
|
|
33
|
+
resetUserData,
|
|
34
|
+
setConfig,
|
|
35
|
+
setDiscovery,
|
|
36
|
+
setToken,
|
|
37
|
+
setUserData,
|
|
38
|
+
useAuth
|
|
39
|
+
} from "./chunk-DXZ4T5LX.js";
|
|
40
|
+
import {
|
|
41
|
+
__export
|
|
42
|
+
} from "./chunk-WEAGW6MQ.js";
|
|
43
|
+
|
|
44
|
+
// src/Expo-AuthSession/index.ts
|
|
45
|
+
var Expo_AuthSession_exports = {};
|
|
46
|
+
__export(Expo_AuthSession_exports, {
|
|
47
|
+
LoginButton: () => LoginButton,
|
|
48
|
+
authenticateInteractively: () => authenticateInteractively,
|
|
49
|
+
authenticateSilently: () => authenticateSilently,
|
|
50
|
+
authenticationClientExists: () => authenticationClientExists,
|
|
51
|
+
getAccount: () => getAccount,
|
|
52
|
+
getAccountWeb: () => getAccountWeb,
|
|
53
|
+
getConfig: () => getConfig,
|
|
54
|
+
getDiscovery: () => getDiscovery,
|
|
55
|
+
getToken: () => getToken,
|
|
56
|
+
getUserData: () => getUserData,
|
|
57
|
+
initiateAuthenticationClient: () => initiateAuthenticationClient,
|
|
58
|
+
resetConfig: () => resetConfig,
|
|
59
|
+
resetDiscovery: () => resetDiscovery,
|
|
60
|
+
resetToken: () => resetToken,
|
|
61
|
+
resetUserData: () => resetUserData,
|
|
62
|
+
setConfig: () => setConfig,
|
|
63
|
+
setDiscovery: () => setDiscovery,
|
|
64
|
+
setToken: () => setToken,
|
|
65
|
+
setUserData: () => setUserData,
|
|
66
|
+
signOut: () => signOut,
|
|
67
|
+
useAccount: () => useAccount,
|
|
68
|
+
useAccountNative: () => useAccountNative,
|
|
69
|
+
useAccountWeb: () => useAccountWeb,
|
|
70
|
+
useAuth: () => useAuth,
|
|
71
|
+
useAuthenticate: () => useAuthenticate
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
export {
|
|
75
|
+
Expo_AuthSession_exports
|
|
76
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -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
|
+
};
|
|
@@ -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
|