-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
19 changed files
with
3,084 additions
and
0 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 |
---|---|---|
|
@@ -130,3 +130,6 @@ dist | |
.pnp.* | ||
|
||
docs/api/source/ | ||
|
||
# Playwright test results | ||
test-results/ |
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 @@ | ||
module.exports = { | ||
extends: ["../../../.eslintrc.js", "next/core-web-vitals"], | ||
parserOptions: { | ||
project: "./tsconfig.json", | ||
}, | ||
}; |
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,35 @@ | ||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
/.pnp | ||
.pnp.js | ||
|
||
# testing | ||
/coverage | ||
|
||
# next.js | ||
/.next/ | ||
/out/ | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
*.pem | ||
|
||
# debug | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
.pnpm-debug.log* | ||
|
||
# local env files | ||
.env*.local | ||
|
||
# vercel | ||
.vercel | ||
|
||
# typescript | ||
*.tsbuildinfo |
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,46 @@ | ||
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app). | ||
|
||
## Getting Started | ||
|
||
First, in the root of the project, run: | ||
|
||
```bash | ||
npm run build | ||
``` | ||
|
||
Then, on the `test-app` directory, run: | ||
|
||
```bash | ||
npm ci | ||
``` | ||
|
||
Then run the development server: | ||
|
||
```bash | ||
npm run dev | ||
# or | ||
yarn dev | ||
``` | ||
|
||
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. | ||
|
||
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. | ||
|
||
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`. | ||
|
||
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages. | ||
|
||
## Learn More | ||
|
||
To learn more about Next.js, take a look at the following resources: | ||
|
||
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. | ||
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. | ||
|
||
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! | ||
|
||
## Deploy on Vercel | ||
|
||
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. | ||
|
||
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. |
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,115 @@ | ||
// | ||
// Copyright Inrupt Inc. | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal in | ||
// the Software without restriction, including without limitation the rights to use, | ||
// copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the | ||
// Software, and to permit persons to whom the Software is furnished to do so, | ||
// subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in | ||
// all copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, | ||
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A | ||
// PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
// SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
// | ||
|
||
// Disabling the following prevents from having to install before linting from | ||
// the root. | ||
// eslint-disable-next-line import/no-unresolved | ||
import React, { useState, useEffect } from "react"; | ||
import type { ISessionInfo } from "@inrupt/solid-client-authn-browser"; | ||
import { | ||
login, | ||
logout, | ||
handleIncomingRedirect, | ||
getDefaultSession | ||
} from "@inrupt/solid-client-authn-browser"; | ||
import { | ||
TESTID_LOGIN_BUTTON, | ||
TESTID_LOGOUT_BUTTON, | ||
TESTID_OPENID_PROVIDER_INPUT, | ||
TESTID_SESSION_STATUS | ||
} from "@inrupt/internal-playwright-testids"; | ||
import ProblemDetailsClient from "../problemDetails"; | ||
|
||
const REDIRECT_URL = window.location.href; | ||
const APP_NAME = "Problem Details error client browser-based tests app"; | ||
const DEFAULT_ISSUER = "https://login.inrupt.com/"; | ||
|
||
export default function AppContainer() { | ||
const [sessionInfo, setSessionInfo] = useState<ISessionInfo>(); | ||
const [issuer, setIssuer] = useState<string>(DEFAULT_ISSUER); | ||
|
||
useEffect(() => { | ||
handleIncomingRedirect().then(setSessionInfo).catch(console.error); | ||
}, []); | ||
|
||
const handleLogin = async () => { | ||
try { | ||
// Login will redirect the user away so that they can log in the OIDC issuer, | ||
// and back to the provided redirect URL (which should be controlled by your app). | ||
await login({ | ||
redirectUrl: REDIRECT_URL, | ||
oidcIssuer: issuer, | ||
clientName: APP_NAME | ||
}); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
}; | ||
|
||
const handleLogout = async () => { | ||
await logout(); | ||
setSessionInfo(undefined); | ||
}; | ||
|
||
return ( | ||
<> | ||
<h1>{APP_NAME}</h1> | ||
<p data-testid={TESTID_SESSION_STATUS}> | ||
{sessionInfo?.isLoggedIn | ||
? `Logged in as ${sessionInfo.webId}` | ||
: "Not logged in yet"} | ||
</p> | ||
<form> | ||
<input | ||
data-testid={TESTID_OPENID_PROVIDER_INPUT} | ||
type="text" | ||
value={issuer} | ||
onChange={(e) => { | ||
setIssuer(e.target.value); | ||
}} | ||
/> | ||
<button | ||
data-testid={TESTID_LOGIN_BUTTON} | ||
onClick={async (e) => { | ||
e.preventDefault(); | ||
await handleLogin(); | ||
}} | ||
> | ||
Log In | ||
</button> | ||
<button | ||
data-testid={TESTID_LOGOUT_BUTTON} | ||
onClick={async (e) => { | ||
e.preventDefault(); | ||
await handleLogout(); | ||
}} | ||
> | ||
Log Out | ||
</button> | ||
</form> | ||
{sessionInfo?.isLoggedIn ? ( | ||
<ProblemDetailsClient session={getDefaultSession()} /> | ||
) : ( | ||
<></> | ||
)} | ||
</> | ||
); | ||
} |
Oops, something went wrong.