-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17bfdae
commit d7bddd8
Showing
14 changed files
with
529 additions
and
334 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { NativeAuthClient } from '@multiversx/sdk-native-auth-client'; | ||
import { useConfig } from './useConfig'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
export const useNativeAuthLoginToken = () => { | ||
const [loginToken, setLoginToken] = useState<string>(); | ||
const [nativeAuthClient, setNativeAuthClient] = useState<NativeAuthClient>(); | ||
const { apiAddress } = useConfig(); | ||
|
||
useEffect(() => { | ||
const getToken = async () => { | ||
const client = new NativeAuthClient({ apiUrl: apiAddress }); | ||
const loginToken = await client.initialize(); | ||
|
||
setLoginToken(loginToken); | ||
setNativeAuthClient(client); | ||
}; | ||
|
||
if (apiAddress) { | ||
getToken(); | ||
} | ||
}, [apiAddress]); | ||
|
||
return { | ||
loginToken, | ||
nativeAuthClient, | ||
}; | ||
}; |
Oops, something went wrong.