├── .eslintrc.json
├── public
├── favicon.ico
└── vercel.svg
├── next.config.js
├── next-env.d.ts
├── components
├── LoginError.tsx
├── OnlineUsers.tsx
└── ChatView.tsx
├── .gitignore
├── tsconfig.json
├── pages
├── _document.tsx
├── index.tsx
├── _app.tsx
├── chat.tsx
└── api
│ └── login.ts
├── package.json
├── utils
└── useCache.ts
└── README.md
/.eslintrc.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "next/core-web-vitals"
3 | }
4 |
--------------------------------------------------------------------------------
/public/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ARE/pubnub-auth0-integration/main/public/favicon.ico
--------------------------------------------------------------------------------
/next.config.js:
--------------------------------------------------------------------------------
1 | /** @type {import('next').NextConfig} */
2 | const nextConfig = {
3 | reactStrictMode: true,
4 | swcMinify: true,
5 | }
6 |
7 | module.exports = nextConfig
8 |
--------------------------------------------------------------------------------
/next-env.d.ts:
--------------------------------------------------------------------------------
1 | ///
2 | ///
3 |
4 | // NOTE: This file should not be edited
5 | // see https://nextjs.org/docs/basic-features/typescript for more information.
6 |
--------------------------------------------------------------------------------
/components/LoginError.tsx:
--------------------------------------------------------------------------------
1 | import Alert from '@mui/material/Alert'
2 | import Stack from '@mui/material/Stack'
3 | import Link from 'next/link'
4 |
5 | export default function LoginError() {
6 | return (
7 |
8 |
9 | You must be logged in to see this page!
10 |
11 |
12 | )
13 | }
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2 |
3 | # dependencies
4 | node_modules
5 | .pnp
6 | .pnp.js
7 |
8 | # testing
9 | coverage
10 |
11 | # next.js
12 | .next/
13 | out/
14 |
15 | # production
16 | build
17 |
18 | # misc
19 | .DS_Store
20 | *.pem
21 |
22 | # debug
23 | npm-debug.log*
24 | yarn-debug.log*
25 | yarn-error.log*
26 | .pnpm-debug.log*
27 |
28 | # local env files
29 | .env*.local
30 |
31 | # vercel
32 | .vercel
33 |
34 | # typescript
35 | *.tsbuildinfo
36 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": ["dom", "dom.iterable", "esnext"],
5 | "allowJs": true,
6 | "skipLibCheck": true,
7 | "strict": true,
8 | "forceConsistentCasingInFileNames": true,
9 | "noEmit": true,
10 | "esModuleInterop": true,
11 | "module": "esnext",
12 | "moduleResolution": "node",
13 | "resolveJsonModule": true,
14 | "isolatedModules": true,
15 | "jsx": "preserve",
16 | "incremental": true
17 | },
18 | "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"],
19 | "exclude": ["node_modules"]
20 | }
21 |
--------------------------------------------------------------------------------
/pages/_document.tsx:
--------------------------------------------------------------------------------
1 | import { Html, Head, Main, NextScript } from 'next/document'
2 | import { CssBaseline } from '@mui/material'
3 |
4 | export default function Document() {
5 | return (
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 | )
18 | }
19 |
--------------------------------------------------------------------------------
/pages/index.tsx:
--------------------------------------------------------------------------------
1 | import { useAuth0 } from '@auth0/auth0-react'
2 |
3 | import { Button, Icon, Stack } from '@mui/material'
4 | import Typography from '@mui/material/Typography'
5 |
6 | export default function Home() {
7 | const { loginWithRedirect } = useAuth0()
8 |
9 | return (
10 |
11 |
12 | PubNub + Auth0
13 |
14 |
25 |
26 | )
27 | }
28 |
--------------------------------------------------------------------------------
/pages/_app.tsx:
--------------------------------------------------------------------------------
1 | import { Container } from '@mui/material'
2 | import type { AppProps } from 'next/app'
3 | import Head from 'next/head'
4 |
5 | import { Auth0Provider } from '@auth0/auth0-react'
6 |
7 | export default function MyApp({ Component, pageProps }: AppProps) {
8 | let uri
9 |
10 | if (typeof window !== 'undefined') {
11 | uri = window?.location?.origin
12 | } else {
13 | uri = 'localhost:3000'
14 | }
15 |
16 | return (
17 | <>
18 |
19 |
20 |
21 |
22 |
27 |
28 |
29 |
30 | >
31 | )
32 | }
33 |
--------------------------------------------------------------------------------
/public/vercel.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "client",
3 | "version": "0.1.0",
4 | "private": true,
5 | "scripts": {
6 | "dev": "next dev",
7 | "build": "next build",
8 | "start": "next start",
9 | "lint": "next lint"
10 | },
11 | "dependencies": {
12 | "@auth0/auth0-react": "^1.10.2",
13 | "@emotion/react": "^11.10.0",
14 | "@emotion/styled": "^11.10.0",
15 | "@mui/material": "^5.9.3",
16 | "@types/auth0": "^2.35.3",
17 | "auth0": "^2.42.0",
18 | "express-jwt": "^7.7.5",
19 | "jose": "^4.8.3",
20 | "jwks-rsa": "^2.1.4",
21 | "next": "12.2.3",
22 | "pubnub": "^7.2.0",
23 | "pubnub-react": "^3.0.1",
24 | "react": "18.2.0",
25 | "react-dom": "18.2.0"
26 | },
27 | "devDependencies": {
28 | "@types/node": "18.6.3",
29 | "@types/pubnub": "^7.2.0",
30 | "@types/react": "18.0.15",
31 | "@types/react-dom": "18.0.6",
32 | "eslint": "8.21.0",
33 | "eslint-config-next": "12.2.3",
34 | "typescript": "4.7.4"
35 | },
36 | "prettier": {
37 | "semi": false,
38 | "singleQuote": true,
39 | "printWidth": 120
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/utils/useCache.ts:
--------------------------------------------------------------------------------
1 | import { useMemo, useState } from 'react'
2 |
3 | export type GetCacheEntry = (key: string) => Promise
4 |
5 | export type Cache = {
6 | has(key: string): boolean
7 | get(key: string): T | undefined
8 | set(key: string, entry: T): T
9 | }
10 |
11 | const fetching = new Set()
12 |
13 | export default function useCache(getCacheEntry: GetCacheEntry) {
14 | const [cache, updateCache] = useState