@mezo-org/passport 0.4.0-dev.7 → 0.4.0-dev.9
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/dist/src/hooks/useAuthenticateWithWallet.d.ts.map +1 -1
- package/dist/src/hooks/useAuthenticateWithWallet.js +5 -6
- package/dist/src/hooks/useAuthenticateWithWallet.js.map +1 -1
- package/dist/src/provider.js +1 -1
- package/dist/src/provider.js.map +1 -1
- package/package.json +1 -1
- package/src/hooks/useAuthenticateWithWallet.ts +5 -12
- package/src/provider.ts +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthenticateWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAuthenticateWithWallet.d.ts","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAe,MAAM,uBAAuB,CAAA;AAMpE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AAGrC,iBAAS,yBAAyB,CAChC,mBAAmB,UAAQ,EAC3B,eAAe,GAAE,IAAI,CACnB,eAAe,CAAC,OAAO,CAAC,EACxB,YAAY,GAAG,aAAa,CACxB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgFP;AAED,OAAO,EAAE,yBAAyB,EAAE,CAAA"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useSignMessage } from "wagmi";
|
|
2
|
-
import { useBitcoinAccount } from "@mezo-org/orangekit";
|
|
3
2
|
import { useMutation } from "@tanstack/react-query";
|
|
4
|
-
import { useMemo } from "react";
|
|
5
3
|
import { useCreateAccount } from "./useCreateAccount";
|
|
6
4
|
import { useCreateSession } from "./useCreateSession";
|
|
7
5
|
import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce";
|
|
@@ -10,20 +8,21 @@ import { useGetAccountByAddress } from "./useGetAccountByAddress";
|
|
|
10
8
|
import useWalletAccount from "./useWalletAccount";
|
|
11
9
|
function useAuthenticateWithWallet(shouldCreateAccount = false, mutationOptions = {}) {
|
|
12
10
|
const { address, chainId, connector, networkFamily } = useWalletAccount();
|
|
13
|
-
const { btcAddress } = useBitcoinAccount();
|
|
14
11
|
const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce();
|
|
15
12
|
const { createSessionAsync } = useCreateSession();
|
|
16
13
|
const { createAccountAsync } = useCreateAccount();
|
|
17
14
|
const { signMessageAsync } = useSignMessage();
|
|
18
|
-
const
|
|
19
|
-
|
|
15
|
+
const { refetch: getAccountByAddress } = useGetAccountByAddress(address, {
|
|
16
|
+
enabled: false,
|
|
17
|
+
retry: false,
|
|
18
|
+
});
|
|
20
19
|
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
21
20
|
mutationFn: async () => {
|
|
22
21
|
if (!address) {
|
|
23
22
|
throw new Error("Sign in error: Wallet not connected!");
|
|
24
23
|
}
|
|
25
24
|
const nonce = await ensureNoSessionAndFetchNonce();
|
|
26
|
-
const messageResult = createSignInWithWalletMessage(
|
|
25
|
+
const messageResult = createSignInWithWalletMessage(address, nonce, networkFamily, chainId);
|
|
27
26
|
const signatureResult = await signMessageAsync({
|
|
28
27
|
message: messageResult,
|
|
29
28
|
connector,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAuthenticateWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,
|
|
1
|
+
{"version":3,"file":"useAuthenticateWithWallet.js","sourceRoot":"","sources":["../../../src/hooks/useAuthenticateWithWallet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAA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/src/provider.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createContext, createElement } from "react";
|
|
|
2
2
|
import { AuthApiClient, PortalApiClient } from "./api";
|
|
3
3
|
export const PassportContext = createContext(undefined);
|
|
4
4
|
export function PassportProvider({ environment, authApiUrl, portalApiUrl, children, }) {
|
|
5
|
-
if (environment
|
|
5
|
+
if (environment && !["mainnet", "testnet"].includes(environment)) {
|
|
6
6
|
throw new Error("Wrong environment passed to PassportProvider.");
|
|
7
7
|
}
|
|
8
8
|
return createElement(PassportContext.Provider, {
|
package/dist/src/provider.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAQtD,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAC1C,SAAS,CACV,CAAA;AAcD,MAAM,UAAU,gBAAgB,CAAC,EAC/B,WAAW,EACX,UAAU,EACV,YAAY,EACZ,QAAQ,GACc;IACtB,IAAI,WAAW,
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,OAAO,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,OAAO,CAAA;AAQtD,MAAM,CAAC,MAAM,eAAe,GAAG,aAAa,CAC1C,SAAS,CACV,CAAA;AAcD,MAAM,UAAU,gBAAgB,CAAC,EAC/B,WAAW,EACX,UAAU,EACV,YAAY,EACZ,QAAQ,GACc;IACtB,IAAI,WAAW,IAAI,CAAC,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;QACjE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;IAClE,CAAC;IAED,OAAO,aAAa,CAClB,eAAe,CAAC,QAAQ,EACxB;QACE,KAAK,EAAE;YACL,aAAa,EAAE,IAAI,aAAa,CAAC,WAAW,IAAI,SAAS,EAAE,UAAU,CAAC;YACtE,eAAe,EAAE,IAAI,eAAe,CAClC,WAAW,IAAI,SAAS,EACxB,YAAY,CACb;YACD,WAAW;SACZ;KACF,EACD,QAAQ,CACT,CAAA;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { useSignMessage } from "wagmi"
|
|
2
|
-
import { useBitcoinAccount } from "@mezo-org/orangekit"
|
|
3
2
|
import { MutationOptions, useMutation } from "@tanstack/react-query"
|
|
4
|
-
import { useMemo } from "react"
|
|
5
3
|
import { useCreateAccount } from "./useCreateAccount"
|
|
6
4
|
import { useCreateSession } from "./useCreateSession"
|
|
7
5
|
import { useEnsureNoSessionAndFetchNonce } from "./useEnsureNoSessionAndFetchNonce"
|
|
@@ -18,20 +16,15 @@ function useAuthenticateWithWallet(
|
|
|
18
16
|
> = {},
|
|
19
17
|
) {
|
|
20
18
|
const { address, chainId, connector, networkFamily } = useWalletAccount()
|
|
21
|
-
const { btcAddress } = useBitcoinAccount()
|
|
22
19
|
const { ensureNoSessionAndFetchNonce } = useEnsureNoSessionAndFetchNonce()
|
|
23
20
|
const { createSessionAsync } = useCreateSession()
|
|
24
21
|
const { createAccountAsync } = useCreateAccount()
|
|
25
22
|
const { signMessageAsync } = useSignMessage()
|
|
26
|
-
const walletAddress = useMemo(
|
|
27
|
-
() => (connector?.type === "orangekit" ? btcAddress : address),
|
|
28
|
-
[btcAddress, address, connector],
|
|
29
|
-
)
|
|
30
23
|
|
|
31
|
-
const { refetch: getAccountByAddress } = useGetAccountByAddress(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
24
|
+
const { refetch: getAccountByAddress } = useGetAccountByAddress(address, {
|
|
25
|
+
enabled: false,
|
|
26
|
+
retry: false,
|
|
27
|
+
})
|
|
35
28
|
|
|
36
29
|
const { mutate, mutateAsync, ...signInMutationRestParameters } = useMutation({
|
|
37
30
|
mutationFn: async () => {
|
|
@@ -42,7 +35,7 @@ function useAuthenticateWithWallet(
|
|
|
42
35
|
const nonce = await ensureNoSessionAndFetchNonce()
|
|
43
36
|
|
|
44
37
|
const messageResult = createSignInWithWalletMessage(
|
|
45
|
-
|
|
38
|
+
address,
|
|
46
39
|
nonce,
|
|
47
40
|
networkFamily,
|
|
48
41
|
chainId,
|
package/src/provider.ts
CHANGED
|
@@ -29,7 +29,7 @@ export function PassportProvider({
|
|
|
29
29
|
portalApiUrl,
|
|
30
30
|
children,
|
|
31
31
|
}: PassportProviderProps) {
|
|
32
|
-
if (environment
|
|
32
|
+
if (environment && !["mainnet", "testnet"].includes(environment)) {
|
|
33
33
|
throw new Error("Wrong environment passed to PassportProvider.")
|
|
34
34
|
}
|
|
35
35
|
|