-
-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(playground): integrate playground with client js sdk
integrate playground with client js sdk
- Loading branch information
Showing
11 changed files
with
98 additions
and
128 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ node_modules | |
# production | ||
/packages/*/dist | ||
/packages/*/lib | ||
/packages/*/build | ||
|
||
# logs | ||
logs | ||
|
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,12 @@ | ||
// Need to disable following rulus to mock text-decode/text-encoder and crypto for jsdom | ||
// https://github.com/jsdom/jsdom/issues/1612 | ||
/* eslint-disable @silverhand/fp/no-mutation */ | ||
/* eslint-disable unicorn/prefer-module */ | ||
const { Crypto } = require('@peculiar/webcrypto'); | ||
const fetch = require('node-fetch'); | ||
const { TextDecoder, TextEncoder } = require('text-encoder'); | ||
|
||
global.crypto = new Crypto(); | ||
global.TextEncoder = TextEncoder; | ||
global.TextDecoder = TextDecoder; | ||
global.fetch = fetch; |
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 |
---|---|---|
@@ -1,15 +1,39 @@ | ||
import React from 'react'; | ||
import LogtoClient from '@logto/client'; | ||
import React, { useState, useEffect } from 'react'; | ||
import { Route, Switch } from 'react-router-dom'; | ||
|
||
import { oidcDomain } from '@/consts/url'; | ||
|
||
import LogtoClientContext from './LogtoClientContext'; | ||
import Callback from './pages/Callback'; | ||
import Home from './pages/Home'; | ||
import './scss/normalized.scss'; | ||
|
||
const App = () => ( | ||
<Switch> | ||
<Route exact path="/" component={Home} /> | ||
<Route exact path="/callback" component={Callback} /> | ||
</Switch> | ||
); | ||
const App = () => { | ||
const [logtoClient, setLogtoClient] = useState<LogtoClient | null>(null); | ||
const [loading, setLoading] = useState(true); | ||
|
||
useEffect(() => { | ||
(async () => { | ||
const client = await LogtoClient.create({ | ||
domain: oidcDomain, | ||
clientId: 'foo', | ||
}); | ||
setLogtoClient(client); | ||
setLoading(false); | ||
})(); | ||
}, []); | ||
|
||
return ( | ||
<Switch> | ||
{!loading && ( | ||
<LogtoClientContext.Provider value={logtoClient}> | ||
<Route exact path="/" component={Home} /> | ||
<Route exact path="/callback" component={Callback} /> | ||
</LogtoClientContext.Provider> | ||
)} | ||
</Switch> | ||
); | ||
}; | ||
|
||
export default App; |
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,6 @@ | ||
import LogtoClient from '@logto/client'; | ||
import React from 'react'; | ||
|
||
const LogtoClientContext = React.createContext<LogtoClient | null>(null); | ||
|
||
export default LogtoClientContext; |
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 |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export const baseUrl = `http://${String(process.env.HOST)}:${String(process.env.PORT)}`; | ||
export const oidcUrl = process.env.RAZZLE_OIDC_BASE_URL ?? 'N/A'; | ||
export const oidcDomain = process.env.RAZZLE_OIDC_BASE_DOMAIN ?? 'N/A'; | ||
export const oidcUrl = process.env.RAZZLE_OIDC_BASE_DOMAIN | ||
? `http://${process.env.RAZZLE_OIDC_BASE_DOMAIN}/oidc` | ||
: 'N/A'; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.