From c06152ba26c1babba5fe422528609a9cb036aaf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20=C4=8Cerm=C3=A1k?= Date: Thu, 7 Nov 2024 15:11:11 +0100 Subject: [PATCH 1/8] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Extract=20common=20cod?= =?UTF-8?q?e=20for=20other=20examples=20to=20the=20packages/common=20works?= =?UTF-8?q?pace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- examples/simplewebauthn/.env.template.server | 3 - .../ExampleRouter/ExampleRouter.tsx | 21 - .../ExampleRouter/context/index.ts | 23 - .../ExampleRouter/hooks/useExampleRouter.ts | 13 - .../FirebaseExample/ExampleRouter/index.ts | 2 - .../ExampleRoutes/ExampleRoutes.tsx | 19 - .../FirebaseExample/ExampleRoutes/index.ts | 1 - .../hooks/useExampleRouteTitle.ts | 20 - .../FirebaseExample/FirebaseExample.tsx | 29 - .../FirebaseExample/index.ts | 1 - .../PasskeysWithFirebasePage.styles.ts | 17 - .../PasskeysWithFirebasePage/index.ts | 1 - .../src/modules/passkeys/components/index.ts | 1 - examples/simplewebauthn/src/pages/index.tsx | 3 - examples/simplewebauthn/tsconfig.json | 12 - .../.env.template.local | 3 + .../webauthn-default/.env.template.server | 6 + .../.gitignore | 0 .../.madgerc | 0 .../README.md | 4 +- .../eslint.config.mjs | 0 .../next-env.d.ts | 0 .../next.config.ts | 8 +- examples/webauthn-default/package.json | 29 + .../public/manifest.json | 2 +- .../sentry.client.config.ts | 2 +- .../sentry.edge.config.ts | 2 +- .../sentry.server.config.ts | 2 +- .../AuthFormContainer.styles.tsx | 2 +- .../AuthFormContainer/index.ts | 0 .../DefaultExample/DefaultExample.tsx | 25 + .../DefaultExampleRouter.tsx | 27 + .../DefaultExampleRouter/index.ts | 1 + .../DefaultExampleTopBar.tsx | 22 + .../hooks/useExampleRouteTitle.ts | 21 + .../DefaultExampleTopBar/index.ts | 1 + .../LoginWithPasskey/LoginWithPasskey.tsx | 12 +- .../hooks/useConditionalMediation.ts | 30 +- .../hooks/useLoginWithPasskey.ts | 31 +- .../DefaultExample}/LoginWithPasskey/index.ts | 0 .../LoginWithPasskey/schema/index.ts | 2 +- .../Passkeys/Passkeys.styles.ts | 15 + .../DefaultExample}/Passkeys/Passkeys.tsx | 11 +- .../PostRemovalDialog.styles.ts | 2 +- .../PostRemovalDialog/PostRemovalDialog.tsx | 11 +- .../Passkeys/PostRemovalDialog/index.ts | 0 .../Passkeys/hooks/useAddPasskey.ts | 17 +- .../Passkeys/hooks/useFetchPasskeys.ts | 5 +- .../Passkeys/hooks/useRemovePasskey.ts | 23 +- .../DefaultExample}/Passkeys/index.ts | 0 .../RegisterWithPasskey.tsx | 9 +- .../RegisterWithPasskey/hooks/index.ts | 0 .../hooks/useRegisterWithPasskey.ts | 28 +- .../RegisterWithPasskey/index.ts | 0 .../RegisterWithPasskey/schema/index.ts | 2 +- .../DefaultExample/index.ts | 1 + .../DefaultExample/routes/index.tsx | 14 + .../WebAuthnDefaultExamplePage.tsx} | 13 +- .../WebAuthnDefaultExamplePage/index.ts | 1 + .../src/instrumentation.ts | 0 examples/webauthn-default/src/pages/_app.tsx | 3 + .../webauthn-default/src/pages/_document.tsx | 3 + .../webauthn-default/src/pages/_error.jsx | 3 + .../src/pages/api/webauthn}/link/options.ts | 15 +- .../src/pages/api/webauthn}/link/verify.ts | 10 +- .../src/pages/api/webauthn}/login/options.ts | 10 +- .../src/pages/api/webauthn}/login/verify.ts | 10 +- .../pages/api/webauthn}/register/options.ts | 12 +- .../pages/api/webauthn}/register/verify.ts | 10 +- .../src/pages/api/webauthn}/remove/options.ts | 11 +- .../src/pages/api/webauthn}/remove/verify.ts | 14 +- examples/webauthn-default/src/pages/index.tsx | 3 + examples/webauthn-default/tsconfig.json | 23 + packages/{ui => common}/.madgerc | 0 packages/common/README.md | 3 + .../AppQueryProvider/AppQueryProvider.tsx | 2 +- .../api/components/AppQueryProvider/index.ts | 0 .../api/components/QueryError/QueryError.tsx | 2 +- .../api/components/QueryError/index.ts | 0 .../components/QueryLoader/QueryLoader.tsx | 2 +- .../api/components/QueryLoader/index.ts | 0 .../RefetchButton/RefetchButton.tsx | 4 +- .../api/components/RefetchButton/index.ts | 0 .../common/client}/api/components/index.ts | 0 .../common/client}/api/fetcher/index.ts | 0 .../CopyToClipboardInput.styles.ts | 2 +- .../CopyToClipboardInput.tsx | 2 +- .../components}/CopyToClipboardInput/index.ts | 0 .../client/clipboard/components/index.ts | 1 + .../common/client/clipboard}/hooks/index.ts | 1 - .../hooks/useCopyTextToClipboard.ts | 2 +- .../common/client/core/components/App.tsx | 11 +- .../client/core/components/Document.tsx | 13 +- .../common/client/core/components/Error.tsx | 10 +- .../common/client/core/components/index.ts | 3 + packages/common/client/dialog/hooks/index.ts | 1 + .../common/client/dialog}/hooks/useDialog.ts | 0 .../common/client}/env/env.mjs | 10 +- .../common/client}/env/index.ts | 0 .../ExampleAuth/AuthLoader/AuthLoader.tsx | 2 +- .../ExampleAuth/AuthLoader/index.ts | 0 .../ExampleAuth/AuthProvider/AuthProvider.tsx | 4 +- .../AuthProvider/contexts/index.ts | 0 .../AuthProvider/hooks/useAuthUser.ts | 0 .../hooks/useExampleAuthSession.ts | 0 .../ExampleAuth/AuthProvider/index.ts | 0 .../components}/ExampleAuth/ExampleAuth.tsx | 0 .../example/components}/ExampleAuth/index.ts | 0 .../ExampleBody/ExampleBody.styles.tsx | 2 +- .../example/components}/ExampleBody/index.ts | 0 .../ExampleDescription.styles.ts | 2 +- .../ExampleDescription/ExampleDescription.tsx | 2 +- .../components/ExampleDescription/index.ts | 0 .../ExampleFrame/ExampleFrame.styles.ts | 0 .../components/ExampleFrame/ExampleFrame.tsx | 0 .../example}/components/ExampleFrame/index.ts | 0 .../ExampleHeader/ExampleHeader.tsx | 2 +- .../components/ExampleHeader/index.ts | 0 .../ExampleRouter/createExampleRouter.tsx | 55 + .../example/components/ExampleRouter/index.ts | 1 + .../AuthUserDropdown.styles.ts | 2 +- .../AuthUserDropdown/AuthUserDropdown.tsx | 17 +- .../AuthUserDropdown/hooks/useLogout.ts | 8 +- .../ExampleTopBar/AuthUserDropdown/index.ts | 0 .../ExampleTopBar/ExampleTopBar.styles.ts | 2 +- .../ExampleTopBar/ExampleTopBar.tsx | 16 +- .../components}/ExampleTopBar/index.ts | 0 .../ExampleWrapper/ExampleWrapper.styles.ts | 7 + .../components/ExampleWrapper/index.ts | 1 + .../common/client/example/components/index.ts | 8 + .../common/client}/firebase/config/index.ts | 9 +- .../client}/firebase/services/passkeys.ts | 7 +- .../form/components/EmailField/EmailField.tsx | 4 +- .../form/components/EmailField/index.ts | 0 .../FieldsStack/FieldsStack.styles.ts | 2 +- .../form/components/FieldsStack/index.ts | 0 .../client}/form/components/Form/Form.tsx | 5 +- .../client}/form/components/Form/index.ts | 0 .../form/components/FormError/FormError.tsx | 0 .../form/components/FormError/index.ts | 0 .../PasswordField/PasswordField.tsx | 3 +- .../TogglePasswordVisibility.tsx | 6 +- .../TogglePasswordVisibility/index.ts | 0 .../form/components/PasswordField/index.ts | 0 .../components/SubmitButton/SubmitButton.tsx | 2 +- .../form/components/SubmitButton/index.ts | 0 .../fields/SelectField/SelectField.tsx | 3 +- .../components/fields/SelectField/index.ts | 0 .../fields/TextField/TextField.styles.ts | 2 +- .../components/fields/TextField/TextField.tsx | 3 +- .../form/components/fields/TextField/index.ts | 0 .../client}/form/components/fields/index.ts | 0 .../common/client}/form/components/index.ts | 2 + .../components/inputs/Select/Select.styles.ts | 0 .../form/components/inputs/Select/Select.tsx | 0 .../form/components/inputs/Select/index.ts | 0 .../inputs/TextInput/TextInput.styles.ts | 0 .../components/inputs/TextInput/TextInput.tsx | 0 .../form/components/inputs/TextInput/index.ts | 0 .../client}/form/components/inputs/index.ts | 0 .../common/client}/form/errors/index.ts | 0 .../common/client}/form/hooks/index.ts | 0 .../form/hooks/useLocalizedResolver.ts | 5 +- packages/common/client/form/types/index.ts | 5 + .../common/client}/form/validators/general.ts | 0 .../common/client}/form/validators/index.ts | 0 .../client}/form/validators/password.ts | 0 .../components/MainHeader/MainHeader.tsx | 2 +- .../layout/components/MainHeader/index.ts | 0 .../common/client}/layout/components/index.ts | 0 .../components}/Passkey/BackedUp/BackedUp.tsx | 4 +- .../components}/Passkey/BackedUp/index.ts | 0 .../Passkey/Caption/Caption.styles.ts | 2 +- .../components}/Passkey/Caption/Caption.tsx | 2 +- .../components}/Passkey/Caption/index.ts | 0 .../components}/Passkey/Counter/Counter.tsx | 2 +- .../components}/Passkey/Counter/index.ts | 0 .../Passkey/DeviceType/DeviceType.tsx | 8 +- .../components}/Passkey/DeviceType/index.ts | 0 .../components/Passkey/Passkey.styles.ts | 16 +- .../passkeys/components}/Passkey/Passkey.tsx | 12 +- .../Passkey/PasskeyID/PasskeyID.tsx | 5 +- .../components}/Passkey/PasskeyID/index.ts | 0 .../components}/Passkey/Provider/Provider.tsx | 2 +- .../components}/Passkey/Provider/index.ts | 0 .../ProviderProfile/ProviderProfile.tsx | 2 +- .../Passkey/ProviderProfile/index.ts | 0 .../Passkey/PublicKey/PublicKey.tsx | 4 +- .../components}/Passkey/PublicKey/index.ts | 0 .../Passkey/RelativeTime/RelativeTime.tsx | 2 +- .../components}/Passkey/RelativeTime/index.ts | 0 .../RelayingPartyId/RelayingPartyId.tsx | 2 +- .../Passkey/RelayingPartyId/index.ts | 0 .../Passkey/Transports/Transports.styles.ts | 2 +- .../Passkey/Transports/Transports.tsx | 10 +- .../Passkey/Transports/constants/index.ts | 17 +- .../components}/Passkey/Transports/index.ts | 0 .../passkeys/components}/Passkey/index.ts | 0 .../client/passkeys/components/index.ts | 1 + .../SnackbarProvider.styles.ts | 3 +- .../SnackbarProvider/SnackbarProvider.tsx | 0 .../components/SnackbarProvider/index.ts | 0 .../client}/snackbar/components/index.ts | 0 .../common/client}/snackbar/hooks/index.ts | 0 .../client}/snackbar/hooks/useSnack.tsx | 2 +- .../ui-kit}/components/Button/Button.tsx | 0 .../client/ui-kit}/components/Button/index.ts | 0 .../ui-kit}/components/Card/Card.styles.tsx | 0 .../client/ui-kit}/components/Card/index.ts | 0 .../ui-kit}/components/Code/Code.styles.ts | 0 .../client/ui-kit}/components/Code/index.ts | 0 .../components/ExternalLink/ExternalLink.tsx | 0 .../ui-kit}/components/ExternalLink/index.ts | 0 .../Features/CategoryName/CategoryName.tsx | 0 .../components/Features/CategoryName/index.ts | 0 .../components/Features/Feature/Feature.tsx | 0 .../components/Features/Feature/index.ts | 0 .../components/Features/Features.styles.ts | 0 .../ui-kit}/components/Features/Features.tsx | 0 .../ui-kit}/components/Features/index.ts | 0 .../ui-kit}/components/Icon/Icon.styles.ts | 0 .../client/ui-kit}/components/Icon/Icon.tsx | 0 .../client/ui-kit}/components/Icon/index.ts | 0 .../InfoTooltip/InfoTooltip.styles.tsx | 0 .../components/InfoTooltip/InfoTooltip.tsx | 0 .../ui-kit}/components/InfoTooltip/index.ts | 0 .../components/Loader/Loader.styles.ts | 0 .../ui-kit}/components/Loader/Loader.tsx | 0 .../client/ui-kit}/components/Loader/index.ts | 0 .../components/MenuItem/MenuItem.styles.ts | 0 .../ui-kit}/components/MenuItem/MenuItem.tsx | 0 .../ui-kit}/components/MenuItem/index.ts | 0 .../components/PageHeader/PageHeader.tsx | 0 .../ui-kit}/components/PageHeader/index.ts | 0 .../ui-kit}/components/Words/Words.styles.ts | 0 .../client/ui-kit}/components/Words/Words.tsx | 0 .../client/ui-kit}/components/Words/index.ts | 0 .../client/ui-kit}/components/index.ts | 3 - .../{ui => common/client/ui-kit}/icons.ts | 0 packages/common/client/ui-kit/index.ts | 2 + .../{ui/src => common/client/ui-kit}/mui.ts | 0 .../EmotionClient/EmotionClient.tsx | 0 .../styles/components/EmotionClient/index.ts | 0 .../ThemeProvider/ThemeProvider.tsx | 0 .../styles/components/ThemeProvider/index.ts | 0 .../client/ui-kit}/styles/index.ts | 0 .../client/ui-kit}/styles/theme/color.ts | 0 .../client/ui-kit}/styles/theme/dimensions.ts | 0 .../client/ui-kit}/styles/theme/index.ts | 0 .../client/ui-kit}/styles/theme/muiTheme.tsx | 0 .../client/ui-kit}/styles/theme/typography.ts | 0 .../styles/utils/createEmotionCache.ts | 0 .../utils/createEmotionCacheWithStyleTags.tsx | 0 .../client/ui-kit}/utils/link.ts | 0 .../common/client/webauthn}/utils/index.ts | 0 .../webauthn}/utils/parseWebAuthnError.ts | 0 packages/{ui => common}/eslint.config.mjs | 0 .../src => packages/common}/logger/index.ts | 2 +- .../common}/package.json | 33 +- .../common}/server/config/firebase.ts | 6 +- .../common}/server/constants/collections.ts | 0 .../common}/server/constants/relyingParty.ts | 0 .../common}/server/env/index.ts | 2 + .../common}/server/scripts/deleteAllUsers.ts | 0 .../services/aaguid/combined_aaguid.json | 0 .../common}/server/services/aaguid/index.ts | 0 .../common}/server/services/auth/index.ts | 0 .../services/challenge-session/cookies.ts | 2 +- .../server/services/challenge-session/db.ts | 2 +- .../services/challenge-session/index.ts | 4 +- .../common}/server/services/passkeys/index.ts | 2 +- .../common}/server/services/users/index.ts | 2 +- .../common}/server/utils/cookies.ts | 0 packages/common/server/utils/index.ts | 5 + .../server/utils/parseAndVerifyIdToken.ts | 3 +- .../utils/parseAuthenticationResponse.ts | 0 .../server/utils/parseRegistrationResponse.ts | 2 +- .../common}/server/utils/relyingParty.ts | 0 packages/common/tsconfig.json | 16 + .../server => packages/common}/types/index.ts | 8 +- packages/logger/package.json | 4 +- packages/ui/.storybook/globals.css | 3 - packages/ui/.storybook/main.ts | 9 - packages/ui/.storybook/preview.tsx | 21 - packages/ui/index.ts | 1 - packages/ui/next-env.d.ts | 5 - packages/ui/package.json | 44 - packages/ui/src/index.ts | 5 - .../ui/src/modules/form/components/index.ts | 4 - .../inputs/Select/Select.stories.tsx | 51 - .../inputs/TextInput/TextInput.stories.tsx | 92 - packages/ui/src/modules/form/types/index.ts | 1 - packages/ui/tsconfig.json | 8 - turbo.json | 2 +- yarn.lock | 7379 ++--------------- 296 files changed, 1289 insertions(+), 7473 deletions(-) delete mode 100644 examples/simplewebauthn/.env.template.server delete mode 100644 examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/ExampleRouter.tsx delete mode 100644 examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/context/index.ts delete mode 100644 examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/hooks/useExampleRouter.ts delete mode 100644 examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/index.ts delete mode 100644 examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRoutes/ExampleRoutes.tsx delete mode 100644 examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRoutes/index.ts delete mode 100644 examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/hooks/useExampleRouteTitle.ts delete mode 100644 examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/FirebaseExample.tsx delete mode 100644 examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/index.ts delete mode 100644 examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/PasskeysWithFirebasePage.styles.ts delete mode 100644 examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/index.ts delete mode 100644 examples/simplewebauthn/src/modules/passkeys/components/index.ts delete mode 100644 examples/simplewebauthn/src/pages/index.tsx delete mode 100755 examples/simplewebauthn/tsconfig.json rename examples/{simplewebauthn => webauthn-default}/.env.template.local (86%) create mode 100644 examples/webauthn-default/.env.template.server rename examples/{simplewebauthn => webauthn-default}/.gitignore (100%) rename examples/{simplewebauthn => webauthn-default}/.madgerc (100%) rename examples/{simplewebauthn => webauthn-default}/README.md (90%) rename examples/{simplewebauthn => webauthn-default}/eslint.config.mjs (100%) rename examples/{simplewebauthn => webauthn-default}/next-env.d.ts (100%) rename examples/{simplewebauthn => webauthn-default}/next.config.ts (93%) create mode 100644 examples/webauthn-default/package.json rename examples/{simplewebauthn => webauthn-default}/public/manifest.json (83%) rename examples/{simplewebauthn => webauthn-default}/sentry.client.config.ts (95%) rename examples/{simplewebauthn => webauthn-default}/sentry.edge.config.ts (94%) rename examples/{simplewebauthn => webauthn-default}/sentry.server.config.ts (92%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/AuthFormContainer/AuthFormContainer.styles.tsx (77%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/AuthFormContainer/index.ts (100%) create mode 100644 examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExample.tsx create mode 100644 examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleRouter/DefaultExampleRouter.tsx create mode 100644 examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleRouter/index.ts create mode 100644 examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleTopBar/DefaultExampleTopBar.tsx create mode 100644 examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleTopBar/hooks/useExampleRouteTitle.ts create mode 100644 examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleTopBar/index.ts rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/LoginWithPasskey/LoginWithPasskey.tsx (86%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/LoginWithPasskey/hooks/useConditionalMediation.ts (68%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/LoginWithPasskey/hooks/useLoginWithPasskey.ts (63%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/LoginWithPasskey/index.ts (100%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/LoginWithPasskey/schema/index.ts (76%) create mode 100644 examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/Passkeys.styles.ts rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/Passkeys/Passkeys.tsx (85%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/Passkeys/PostRemovalDialog/PostRemovalDialog.styles.ts (82%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/Passkeys/PostRemovalDialog/PostRemovalDialog.tsx (84%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/Passkeys/PostRemovalDialog/index.ts (100%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/Passkeys/hooks/useAddPasskey.ts (67%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/Passkeys/hooks/useFetchPasskeys.ts (66%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/Passkeys/hooks/useRemovePasskey.ts (70%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/Passkeys/index.ts (100%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/RegisterWithPasskey/RegisterWithPasskey.tsx (82%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/RegisterWithPasskey/hooks/index.ts (100%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/RegisterWithPasskey/hooks/useRegisterWithPasskey.ts (66%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/RegisterWithPasskey/index.ts (100%) rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample}/RegisterWithPasskey/schema/index.ts (76%) create mode 100644 examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/index.ts create mode 100644 examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/routes/index.tsx rename examples/{simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/PasskeysWithFirebasePage.tsx => webauthn-default/src/components/WebAuthnDefaultExamplePage/WebAuthnDefaultExamplePage.tsx} (79%) create mode 100644 examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/index.ts rename examples/{simplewebauthn => webauthn-default}/src/instrumentation.ts (100%) create mode 100755 examples/webauthn-default/src/pages/_app.tsx create mode 100644 examples/webauthn-default/src/pages/_document.tsx create mode 100644 examples/webauthn-default/src/pages/_error.jsx rename examples/{simplewebauthn/src/pages/api/authentication/with-firebase => webauthn-default/src/pages/api/webauthn}/link/options.ts (87%) rename examples/{simplewebauthn/src/pages/api/authentication/with-firebase => webauthn-default/src/pages/api/webauthn}/link/verify.ts (84%) rename examples/{simplewebauthn/src/pages/api/authentication/with-firebase => webauthn-default/src/pages/api/webauthn}/login/options.ts (89%) rename examples/{simplewebauthn/src/pages/api/authentication/with-firebase => webauthn-default/src/pages/api/webauthn}/login/verify.ts (89%) rename examples/{simplewebauthn/src/pages/api/authentication/with-firebase => webauthn-default/src/pages/api/webauthn}/register/options.ts (88%) rename examples/{simplewebauthn/src/pages/api/authentication/with-firebase => webauthn-default/src/pages/api/webauthn}/register/verify.ts (86%) rename examples/{simplewebauthn/src/pages/api/authentication/with-firebase => webauthn-default/src/pages/api/webauthn}/remove/options.ts (86%) rename examples/{simplewebauthn/src/pages/api/authentication/with-firebase => webauthn-default/src/pages/api/webauthn}/remove/verify.ts (84%) create mode 100644 examples/webauthn-default/src/pages/index.tsx create mode 100755 examples/webauthn-default/tsconfig.json rename packages/{ui => common}/.madgerc (100%) create mode 100644 packages/common/README.md rename {examples/simplewebauthn/src/modules => packages/common/client}/api/components/AppQueryProvider/AppQueryProvider.tsx (97%) rename {examples/simplewebauthn/src/modules => packages/common/client}/api/components/AppQueryProvider/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/api/components/QueryError/QueryError.tsx (93%) rename {examples/simplewebauthn/src/modules => packages/common/client}/api/components/QueryError/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/api/components/QueryLoader/QueryLoader.tsx (97%) rename {examples/simplewebauthn/src/modules => packages/common/client}/api/components/QueryLoader/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/api/components/RefetchButton/RefetchButton.tsx (89%) rename {examples/simplewebauthn/src/modules => packages/common/client}/api/components/RefetchButton/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/api/components/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/api/fetcher/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey => packages/common/client/clipboard/components}/CopyToClipboardInput/CopyToClipboardInput.styles.ts (87%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey => packages/common/client/clipboard/components}/CopyToClipboardInput/CopyToClipboardInput.tsx (87%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey => packages/common/client/clipboard/components}/CopyToClipboardInput/index.ts (100%) create mode 100644 packages/common/client/clipboard/components/index.ts rename {examples/simplewebauthn/src => packages/common/client/clipboard}/hooks/index.ts (59%) rename {examples/simplewebauthn/src => packages/common/client/clipboard}/hooks/useCopyTextToClipboard.ts (92%) rename examples/simplewebauthn/src/pages/_app.tsx => packages/common/client/core/components/App.tsx (71%) mode change 100755 => 100644 rename examples/simplewebauthn/src/pages/_document.tsx => packages/common/client/core/components/Document.tsx (84%) rename examples/simplewebauthn/src/pages/_error.jsx => packages/common/client/core/components/Error.tsx (58%) create mode 100644 packages/common/client/core/components/index.ts create mode 100644 packages/common/client/dialog/hooks/index.ts rename {examples/simplewebauthn/src => packages/common/client/dialog}/hooks/useDialog.ts (100%) rename {examples/simplewebauthn/src => packages/common/client}/env/env.mjs (87%) rename {examples/simplewebauthn/src => packages/common/client}/env/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleAuth/AuthLoader/AuthLoader.tsx (78%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleAuth/AuthLoader/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleAuth/AuthProvider/AuthProvider.tsx (94%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleAuth/AuthProvider/contexts/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleAuth/AuthProvider/hooks/useAuthUser.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleAuth/AuthProvider/hooks/useExampleAuthSession.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleAuth/AuthProvider/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleAuth/ExampleAuth.tsx (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleAuth/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleBody/ExampleBody.styles.tsx (85%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleBody/index.ts (100%) rename packages/{ui/src => common/client/example}/components/ExampleDescription/ExampleDescription.styles.ts (85%) rename packages/{ui/src => common/client/example}/components/ExampleDescription/ExampleDescription.tsx (93%) rename packages/{ui/src => common/client/example}/components/ExampleDescription/index.ts (100%) rename packages/{ui/src => common/client/example}/components/ExampleFrame/ExampleFrame.styles.ts (100%) rename packages/{ui/src => common/client/example}/components/ExampleFrame/ExampleFrame.tsx (100%) rename packages/{ui/src => common/client/example}/components/ExampleFrame/index.ts (100%) rename packages/{ui/src => common/client/example}/components/ExampleHeader/ExampleHeader.tsx (91%) rename packages/{ui/src => common/client/example}/components/ExampleHeader/index.ts (100%) create mode 100644 packages/common/client/example/components/ExampleRouter/createExampleRouter.tsx create mode 100644 packages/common/client/example/components/ExampleRouter/index.ts rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.styles.ts (80%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.tsx (75%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleTopBar/AuthUserDropdown/hooks/useLogout.ts (59%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleTopBar/AuthUserDropdown/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleTopBar/ExampleTopBar.styles.ts (88%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleTopBar/ExampleTopBar.tsx (70%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample => packages/common/client/example/components}/ExampleTopBar/index.ts (100%) create mode 100644 packages/common/client/example/components/ExampleWrapper/ExampleWrapper.styles.ts create mode 100644 packages/common/client/example/components/ExampleWrapper/index.ts create mode 100644 packages/common/client/example/components/index.ts rename {examples/simplewebauthn/src/modules => packages/common/client}/firebase/config/index.ts (81%) rename {examples/simplewebauthn/src/modules => packages/common/client}/firebase/services/passkeys.ts (77%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/components/EmailField/EmailField.tsx (88%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/components/EmailField/index.ts (100%) rename packages/{ui/src/modules => common/client}/form/components/FieldsStack/FieldsStack.styles.ts (78%) rename packages/{ui/src/modules => common/client}/form/components/FieldsStack/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/components/Form/Form.tsx (88%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/components/Form/index.ts (100%) rename packages/{ui/src/modules => common/client}/form/components/FormError/FormError.tsx (100%) rename packages/{ui/src/modules => common/client}/form/components/FormError/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/components/PasswordField/PasswordField.tsx (88%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/components/PasswordField/TogglePasswordVisibility/TogglePasswordVisibility.tsx (80%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/components/PasswordField/TogglePasswordVisibility/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/components/PasswordField/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/components/SubmitButton/SubmitButton.tsx (88%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/components/SubmitButton/index.ts (100%) rename packages/{ui/src/modules => common/client}/form/components/fields/SelectField/SelectField.tsx (96%) rename packages/{ui/src/modules => common/client}/form/components/fields/SelectField/index.ts (100%) rename packages/{ui/src/modules => common/client}/form/components/fields/TextField/TextField.styles.ts (89%) rename packages/{ui/src/modules => common/client}/form/components/fields/TextField/TextField.tsx (96%) rename packages/{ui/src/modules => common/client}/form/components/fields/TextField/index.ts (100%) rename packages/{ui/src/modules => common/client}/form/components/fields/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/components/index.ts (66%) rename packages/{ui/src/modules => common/client}/form/components/inputs/Select/Select.styles.ts (100%) rename packages/{ui/src/modules => common/client}/form/components/inputs/Select/Select.tsx (100%) rename packages/{ui/src/modules => common/client}/form/components/inputs/Select/index.ts (100%) rename packages/{ui/src/modules => common/client}/form/components/inputs/TextInput/TextInput.styles.ts (100%) rename packages/{ui/src/modules => common/client}/form/components/inputs/TextInput/TextInput.tsx (100%) rename packages/{ui/src/modules => common/client}/form/components/inputs/TextInput/index.ts (100%) rename packages/{ui/src/modules => common/client}/form/components/inputs/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/errors/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/hooks/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/hooks/useLocalizedResolver.ts (92%) create mode 100644 packages/common/client/form/types/index.ts rename {examples/simplewebauthn/src/modules => packages/common/client}/form/validators/general.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/validators/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/form/validators/password.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/layout/components/MainHeader/MainHeader.tsx (88%) rename {examples/simplewebauthn/src/modules => packages/common/client}/layout/components/MainHeader/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/layout/components/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/BackedUp/BackedUp.tsx (89%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/BackedUp/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/Caption/Caption.styles.ts (80%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/Caption/Caption.tsx (90%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/Caption/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/Counter/Counter.tsx (91%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/Counter/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/DeviceType/DeviceType.tsx (88%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/DeviceType/index.ts (100%) rename examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkeys.styles.ts => packages/common/client/passkeys/components/Passkey/Passkey.styles.ts (58%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/Passkey.tsx (88%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/PasskeyID/PasskeyID.tsx (84%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/PasskeyID/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/Provider/Provider.tsx (95%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/Provider/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/ProviderProfile/ProviderProfile.tsx (92%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/ProviderProfile/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/PublicKey/PublicKey.tsx (83%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/PublicKey/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/RelativeTime/RelativeTime.tsx (91%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/RelativeTime/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/RelayingPartyId/RelayingPartyId.tsx (95%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/RelayingPartyId/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/Transports/Transports.styles.ts (89%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/Transports/Transports.tsx (93%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/Transports/constants/index.ts (80%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/Transports/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys => packages/common/client/passkeys/components}/Passkey/index.ts (100%) create mode 100644 packages/common/client/passkeys/components/index.ts rename {examples/simplewebauthn/src/modules => packages/common/client}/snackbar/components/SnackbarProvider/SnackbarProvider.styles.ts (96%) rename {examples/simplewebauthn/src/modules => packages/common/client}/snackbar/components/SnackbarProvider/SnackbarProvider.tsx (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/snackbar/components/SnackbarProvider/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/snackbar/components/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/snackbar/hooks/index.ts (100%) rename {examples/simplewebauthn/src/modules => packages/common/client}/snackbar/hooks/useSnack.tsx (94%) rename packages/{ui/src => common/client/ui-kit}/components/Button/Button.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/Button/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Card/Card.styles.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/Card/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Code/Code.styles.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Code/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/ExternalLink/ExternalLink.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/ExternalLink/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Features/CategoryName/CategoryName.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/Features/CategoryName/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Features/Feature/Feature.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/Features/Feature/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Features/Features.styles.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Features/Features.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/Features/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Icon/Icon.styles.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Icon/Icon.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/Icon/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/InfoTooltip/InfoTooltip.styles.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/InfoTooltip/InfoTooltip.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/InfoTooltip/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Loader/Loader.styles.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Loader/Loader.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/Loader/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/MenuItem/MenuItem.styles.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/MenuItem/MenuItem.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/MenuItem/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/PageHeader/PageHeader.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/PageHeader/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Words/Words.styles.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/Words/Words.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/components/Words/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/components/index.ts (74%) rename packages/{ui => common/client/ui-kit}/icons.ts (100%) create mode 100644 packages/common/client/ui-kit/index.ts rename packages/{ui/src => common/client/ui-kit}/mui.ts (100%) rename packages/{ui/src => common/client/ui-kit}/styles/components/EmotionClient/EmotionClient.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/styles/components/EmotionClient/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/styles/components/ThemeProvider/ThemeProvider.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/styles/components/ThemeProvider/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/styles/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/styles/theme/color.ts (100%) rename packages/{ui/src => common/client/ui-kit}/styles/theme/dimensions.ts (100%) rename packages/{ui/src => common/client/ui-kit}/styles/theme/index.ts (100%) rename packages/{ui/src => common/client/ui-kit}/styles/theme/muiTheme.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/styles/theme/typography.ts (100%) rename packages/{ui/src => common/client/ui-kit}/styles/utils/createEmotionCache.ts (100%) rename packages/{ui/src => common/client/ui-kit}/styles/utils/createEmotionCacheWithStyleTags.tsx (100%) rename packages/{ui/src => common/client/ui-kit}/utils/link.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys => packages/common/client/webauthn}/utils/index.ts (100%) rename {examples/simplewebauthn/src/modules/passkeys => packages/common/client/webauthn}/utils/parseWebAuthnError.ts (100%) rename packages/{ui => common}/eslint.config.mjs (100%) rename {examples/simplewebauthn/src => packages/common}/logger/index.ts (95%) rename {examples/simplewebauthn => packages/common}/package.json (67%) rename {examples/simplewebauthn/src => packages/common}/server/config/firebase.ts (88%) rename {examples/simplewebauthn/src => packages/common}/server/constants/collections.ts (100%) rename {examples/simplewebauthn/src => packages/common}/server/constants/relyingParty.ts (100%) rename {examples/simplewebauthn/src => packages/common}/server/env/index.ts (84%) rename {examples/simplewebauthn/src => packages/common}/server/scripts/deleteAllUsers.ts (100%) rename {examples/simplewebauthn/src => packages/common}/server/services/aaguid/combined_aaguid.json (100%) rename {examples/simplewebauthn/src => packages/common}/server/services/aaguid/index.ts (100%) rename {examples/simplewebauthn/src => packages/common}/server/services/auth/index.ts (100%) rename {examples/simplewebauthn/src => packages/common}/server/services/challenge-session/cookies.ts (97%) rename {examples/simplewebauthn/src => packages/common}/server/services/challenge-session/db.ts (96%) rename {examples/simplewebauthn/src => packages/common}/server/services/challenge-session/index.ts (96%) rename {examples/simplewebauthn/src => packages/common}/server/services/passkeys/index.ts (97%) rename {examples/simplewebauthn/src => packages/common}/server/services/users/index.ts (98%) rename {examples/simplewebauthn/src => packages/common}/server/utils/cookies.ts (100%) create mode 100644 packages/common/server/utils/index.ts rename {examples/simplewebauthn/src => packages/common}/server/utils/parseAndVerifyIdToken.ts (88%) rename {examples/simplewebauthn/src => packages/common}/server/utils/parseAuthenticationResponse.ts (100%) rename {examples/simplewebauthn/src => packages/common}/server/utils/parseRegistrationResponse.ts (95%) rename {examples/simplewebauthn/src => packages/common}/server/utils/relyingParty.ts (100%) create mode 100644 packages/common/tsconfig.json rename {examples/simplewebauthn/src/server => packages/common}/types/index.ts (94%) delete mode 100644 packages/ui/.storybook/globals.css delete mode 100644 packages/ui/.storybook/main.ts delete mode 100644 packages/ui/.storybook/preview.tsx delete mode 100644 packages/ui/index.ts delete mode 100644 packages/ui/next-env.d.ts delete mode 100644 packages/ui/package.json delete mode 100644 packages/ui/src/index.ts delete mode 100644 packages/ui/src/modules/form/components/index.ts delete mode 100644 packages/ui/src/modules/form/components/inputs/Select/Select.stories.tsx delete mode 100644 packages/ui/src/modules/form/components/inputs/TextInput/TextInput.stories.tsx delete mode 100644 packages/ui/src/modules/form/types/index.ts delete mode 100644 packages/ui/tsconfig.json diff --git a/README.md b/README.md index 865e3fa..9a7a7f6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ A repository with full stack WebAuthn API examples. ## Examples -1. **[Passkeys with SimpleWebAuthn & Firebase](examples/simplewebauthn)** +1. **[Default WebAuthn Example - Passkeys with SimpleWebAuthn & Firebase](examples/webauthn-default/README.md)** - Creating (user registration), retrieving (user login), linking multiple, and removing passkeys. - Issuing a JWT token via Firebase Auth once user is authenticated. - Passkes are stored in Firebase Firestore. @@ -47,7 +47,7 @@ A repository with full stack WebAuthn API examples. ``` 3. Then continue with final steps for specific example: - - [Passkeys with SimpleWebAuthn & Firebase](examples/simplewebauthn/README.md) + - [Passkeys with SimpleWebAuthn & Firebase](examples/webauthn-default/README.md) ## Have you a found a bug? diff --git a/examples/simplewebauthn/.env.template.server b/examples/simplewebauthn/.env.template.server deleted file mode 100644 index b1c7f35..0000000 --- a/examples/simplewebauthn/.env.template.server +++ /dev/null @@ -1,3 +0,0 @@ -FIREBASE_PROJECT_ID="" -FIREBASE_PRIVATE_KEY="" -FIREBASE_CLIENT_EMAIL="" diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/ExampleRouter.tsx b/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/ExampleRouter.tsx deleted file mode 100644 index a072baf..0000000 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/ExampleRouter.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import { useState, type ReactNode } from 'react'; - -import { useExampleAuthSession } from '../ExampleAuth'; -import { ExampleRouterContext, type ExampleAuthRoute, type ExampleRoute } from './context'; - -export interface ExampleRouterProps { - children: ReactNode; - initialRoute?: ExampleRoute | ExampleAuthRoute; -} - -/** - * Yes, this not so smart solution but it's just an example, so please focus on the WebAutn part. Thanks. - */ -export const ExampleRouter = ({ children }: ExampleRouterProps) => { - const { session } = useExampleAuthSession(); - const [route, redirect] = useState( - session.state === 'authenticated' ? '/passkeys' : '/register', - ); - - return {children}; -}; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/context/index.ts b/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/context/index.ts deleted file mode 100644 index 5510232..0000000 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/context/index.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { createContext } from 'react'; - -type ValuesOf = T[keyof T]; - -export const exampleRoutes = { - register: '/register', - login: '/login', -} as const satisfies Record; - -export type ExampleRoute = ValuesOf; - -export const exampleAuthRoutes = { - passkeys: '/passkeys', -} as const satisfies Record; - -export type ExampleAuthRoute = ValuesOf; - -export type ExampleRouterContextValue = { - route: ExampleRoute | ExampleAuthRoute; - redirect: (route: ExampleRoute | ExampleAuthRoute) => void; -}; - -export const ExampleRouterContext = createContext(undefined); diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/hooks/useExampleRouter.ts b/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/hooks/useExampleRouter.ts deleted file mode 100644 index 4ac0710..0000000 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/hooks/useExampleRouter.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { useContext } from 'react'; - -import { ExampleRouterContext } from '../context'; - -export function useExampleRouter() { - const context = useContext(ExampleRouterContext); - - if (!context) { - throw new Error('useExampleRouter must be used within an ExampleRouterContext.Provider'); - } - - return context; -} diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/index.ts b/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/index.ts deleted file mode 100644 index 979db1e..0000000 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRouter/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './ExampleRouter'; -export * from './hooks/useExampleRouter'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRoutes/ExampleRoutes.tsx b/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRoutes/ExampleRoutes.tsx deleted file mode 100644 index 21761bb..0000000 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRoutes/ExampleRoutes.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { useExampleRouter } from '../ExampleRouter'; -import { LoginWithPasskey } from '../LoginWithPasskey'; -import { Passkeys } from '../Passkeys'; -import { RegisterWithPasskey } from '../RegisterWithPasskey'; - -export const ExampleRoutes = () => { - const { route } = useExampleRouter(); - - switch (route) { - case '/register': - return ; - - case '/login': - return ; - - case '/passkeys': - return ; - } -}; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRoutes/index.ts b/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRoutes/index.ts deleted file mode 100644 index 64b1b5d..0000000 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleRoutes/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './ExampleRoutes'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/hooks/useExampleRouteTitle.ts b/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/hooks/useExampleRouteTitle.ts deleted file mode 100644 index e48bb19..0000000 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/hooks/useExampleRouteTitle.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { useExampleAuthSession } from '../../ExampleAuth'; -import { useExampleRouter } from '../../ExampleRouter'; -import type { ExampleAuthRoute, ExampleRoute } from '../../ExampleRouter/context'; - -const routeTitles = { - '/passkeys': 'Registered passkeys', - '/register': 'Demo Registration', - '/login': 'Demo Login', -} as const satisfies Record; - -export function useExampleRouteTitle() { - const { session } = useExampleAuthSession(); - const { route } = useExampleRouter(); - - if (session.state === 'loading') { - return 'Loading...'; - } - - return routeTitles[route]; -} diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/FirebaseExample.tsx b/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/FirebaseExample.tsx deleted file mode 100644 index e9ed47f..0000000 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/FirebaseExample.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import { useState } from 'react'; - -import { ExampleFrame } from '@workspace/ui'; - -import { ExampleAuth } from './ExampleAuth'; -import { ExampleBody } from './ExampleBody'; -import { ExampleRouter } from './ExampleRouter'; -import { ExampleRoutes } from './ExampleRoutes'; -import { ExampleTopBar } from './ExampleTopBar'; - -export interface FirebaseExampleProps {} - -export const FirebaseExample = ({}: FirebaseExampleProps) => { - const [expanded, setExpanded] = useState(true); - - return ( - - - - - - - - - - - - ); -}; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/index.ts b/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/index.ts deleted file mode 100644 index 391fa02..0000000 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './FirebaseExample'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/PasskeysWithFirebasePage.styles.ts b/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/PasskeysWithFirebasePage.styles.ts deleted file mode 100644 index fb9e31e..0000000 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/PasskeysWithFirebasePage.styles.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { Container, styled } from '@workspace/ui'; - -export const FeaturesContainer = styled(Container)(({ theme }) => ({ - paddingTop: theme.spacing(7), - paddingBottom: theme.spacing(6), - - display: 'grid', - gridTemplateColumns: '1fr', - justifyContent: 'center', - gap: theme.spacing(5), -})); - -export const ExampleWrapper = styled('div')(({ theme }) => ({ - paddingTop: theme.spacing(7), - paddingBottom: theme.spacing(7), - backgroundColor: theme.palette.grey[100], -})); diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/index.ts b/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/index.ts deleted file mode 100644 index ae09027..0000000 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './PasskeysWithFirebasePage'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/index.ts b/examples/simplewebauthn/src/modules/passkeys/components/index.ts deleted file mode 100644 index ae09027..0000000 --- a/examples/simplewebauthn/src/modules/passkeys/components/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './PasskeysWithFirebasePage'; diff --git a/examples/simplewebauthn/src/pages/index.tsx b/examples/simplewebauthn/src/pages/index.tsx deleted file mode 100644 index 8f71580..0000000 --- a/examples/simplewebauthn/src/pages/index.tsx +++ /dev/null @@ -1,3 +0,0 @@ -import { PasskeysWithFirebasePage } from '~modules/passkeys/components'; - -export default PasskeysWithFirebasePage; diff --git a/examples/simplewebauthn/tsconfig.json b/examples/simplewebauthn/tsconfig.json deleted file mode 100755 index b0dde1a..0000000 --- a/examples/simplewebauthn/tsconfig.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "extends": "@tooling/typescript/nextjs", - "compilerOptions": { - "baseUrl": ".", - "jsx": "preserve", - "paths": { - "~*": ["./src/*"], - "~public/*": ["./public/*"] - } - }, - "include": ["**/*.ts", "**/*.tsx", "**/*.mts"] -} diff --git a/examples/simplewebauthn/.env.template.local b/examples/webauthn-default/.env.template.local similarity index 86% rename from examples/simplewebauthn/.env.template.local rename to examples/webauthn-default/.env.template.local index b5bed0f..fd7c477 100644 --- a/examples/simplewebauthn/.env.template.local +++ b/examples/webauthn-default/.env.template.local @@ -12,6 +12,9 @@ NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID="" NEXT_PUBLIC_FIREBASE_APP_ID="" NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID="" +# Optionally, specify specific Firestore database ID +# NEXT_PUBLIC_FIREBASE_DB_ID="" + # Sentry NEXT_PUBLIC_DEV_SENTRY_DISABLED=true # NEXT_PUBLIC_SENTRY_DSN="" diff --git a/examples/webauthn-default/.env.template.server b/examples/webauthn-default/.env.template.server new file mode 100644 index 0000000..b31fc3b --- /dev/null +++ b/examples/webauthn-default/.env.template.server @@ -0,0 +1,6 @@ +FIREBASE_PROJECT_ID="" +FIREBASE_PRIVATE_KEY="" +FIREBASE_CLIENT_EMAIL="" + +# Optionally, specify specific Firestore database ID +# FIREBASE_DB_ID="" \ No newline at end of file diff --git a/examples/simplewebauthn/.gitignore b/examples/webauthn-default/.gitignore similarity index 100% rename from examples/simplewebauthn/.gitignore rename to examples/webauthn-default/.gitignore diff --git a/examples/simplewebauthn/.madgerc b/examples/webauthn-default/.madgerc similarity index 100% rename from examples/simplewebauthn/.madgerc rename to examples/webauthn-default/.madgerc diff --git a/examples/simplewebauthn/README.md b/examples/webauthn-default/README.md similarity index 90% rename from examples/simplewebauthn/README.md rename to examples/webauthn-default/README.md index baa2a9b..c546975 100644 --- a/examples/simplewebauthn/README.md +++ b/examples/webauthn-default/README.md @@ -1,4 +1,4 @@ -# Passkeys with SimpleWebAuthn & Firebase +# Default WebAuthn Example - Passkeys with SimpleWebAuthn & Firebase - Creating (user registration), retrieving (user login), linking multiple, and removing passkeys. - Issuing a JWT token via Firebase Auth once user is authenticated. @@ -24,7 +24,7 @@ Assuming you've already finished [those steps in the main README](../../README.m 3. Copy `.env.template.server` to `.env.server`: - Create a new private key in `Firebase > Project settings > Service accounts`. - - Fill up all those `Firebase_` env. vars. + - Fill up all those `FIREBASE_` env. vars. 4. Don't forget to add `localhost` as Authorized domain in Firebase: diff --git a/examples/simplewebauthn/eslint.config.mjs b/examples/webauthn-default/eslint.config.mjs similarity index 100% rename from examples/simplewebauthn/eslint.config.mjs rename to examples/webauthn-default/eslint.config.mjs diff --git a/examples/simplewebauthn/next-env.d.ts b/examples/webauthn-default/next-env.d.ts similarity index 100% rename from examples/simplewebauthn/next-env.d.ts rename to examples/webauthn-default/next-env.d.ts diff --git a/examples/simplewebauthn/next.config.ts b/examples/webauthn-default/next.config.ts similarity index 93% rename from examples/simplewebauthn/next.config.ts rename to examples/webauthn-default/next.config.ts index 5bd7e67..9bf73c3 100755 --- a/examples/simplewebauthn/next.config.ts +++ b/examples/webauthn-default/next.config.ts @@ -3,8 +3,6 @@ import { withSentryConfig } from '@sentry/nextjs'; import { config } from 'dotenv'; import type { dependencies } from 'package.json'; -import './src/env/env.mjs'; - if (process.env.NODE_ENV === 'development') { config({ path: '.env.local', @@ -21,11 +19,9 @@ const nextConfig: NextConfig = { defaultLocale: 'en', }, - transpilePackages: ['@workspace/ui', '@workspace/logger'] satisfies Dependency[], + transpilePackages: ['@workspace/common'] satisfies Dependency[], - redirects: async () => { - return []; - }, + redirects: async () => [], }; // Make sure adding Sentry options is the last code to run before exporting, to diff --git a/examples/webauthn-default/package.json b/examples/webauthn-default/package.json new file mode 100644 index 0000000..44ecf26 --- /dev/null +++ b/examples/webauthn-default/package.json @@ -0,0 +1,29 @@ +{ + "name": "webauthn-default-example", + "version": "0.0.1", + "type": "module", + "scripts": { + "dev": "next dev --turbopack", + "build": "next build", + "start": "next start", + "lint": "eslint-lint --config=eslint.config.mjs ./src/**/*.{ts,tsx}", + "lint:fix": "yarn lint --fix", + "format": "prettier-format", + "cir-dep": "check-cir-deps ./src" + }, + "dependencies": { + "@workspace/common": "workspace:*", + "next": "15.0.2" + }, + "devDependencies": { + "@tooling/eslint": "workspace:*", + "@tooling/madge": "workspace:*", + "@tooling/prettier": "workspace:*", + "@tooling/typescript": "workspace:*", + "browserslist-config-custom": "workspace:*" + }, + "prettier": "@tooling/prettier/config", + "browserslist": [ + "extends browserslist-config-custom" + ] +} diff --git a/examples/simplewebauthn/public/manifest.json b/examples/webauthn-default/public/manifest.json similarity index 83% rename from examples/simplewebauthn/public/manifest.json rename to examples/webauthn-default/public/manifest.json index 21b8296..2af852b 100644 --- a/examples/simplewebauthn/public/manifest.json +++ b/examples/webauthn-default/public/manifest.json @@ -6,7 +6,7 @@ "display": "standalone", "dir": "auto", "lang": "en-US", - "name": "With WebAuthn full stack examples", + "name": "With WebAuthn full stack example", "short_name": "With WebAuthn", "start_url": "/" } diff --git a/examples/simplewebauthn/sentry.client.config.ts b/examples/webauthn-default/sentry.client.config.ts similarity index 95% rename from examples/simplewebauthn/sentry.client.config.ts rename to examples/webauthn-default/sentry.client.config.ts index 978bd19..0ca6934 100644 --- a/examples/simplewebauthn/sentry.client.config.ts +++ b/examples/webauthn-default/sentry.client.config.ts @@ -4,7 +4,7 @@ import * as Sentry from '@sentry/nextjs'; -import { env } from '~env'; +import { env } from '@workspace/common/client/env'; if (env.NEXT_PUBLIC_DEV_SENTRY_DISABLED !== 'true') { Sentry.init({ diff --git a/examples/simplewebauthn/sentry.edge.config.ts b/examples/webauthn-default/sentry.edge.config.ts similarity index 94% rename from examples/simplewebauthn/sentry.edge.config.ts rename to examples/webauthn-default/sentry.edge.config.ts index d07564a..ec28548 100644 --- a/examples/simplewebauthn/sentry.edge.config.ts +++ b/examples/webauthn-default/sentry.edge.config.ts @@ -5,7 +5,7 @@ import * as Sentry from '@sentry/nextjs'; -import { env } from '~env'; +import { env } from '@workspace/common/client/env'; if (env.NEXT_PUBLIC_DEV_SENTRY_DISABLED !== 'true') { Sentry.init({ diff --git a/examples/simplewebauthn/sentry.server.config.ts b/examples/webauthn-default/sentry.server.config.ts similarity index 92% rename from examples/simplewebauthn/sentry.server.config.ts rename to examples/webauthn-default/sentry.server.config.ts index 41587ac..e2141fa 100644 --- a/examples/simplewebauthn/sentry.server.config.ts +++ b/examples/webauthn-default/sentry.server.config.ts @@ -4,7 +4,7 @@ import * as Sentry from '@sentry/nextjs'; -import { env } from '~env'; +import { env } from '@workspace/common/client/env'; if (env.NEXT_PUBLIC_DEV_SENTRY_DISABLED !== 'true') { Sentry.init({ diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/AuthFormContainer/AuthFormContainer.styles.tsx b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/AuthFormContainer/AuthFormContainer.styles.tsx similarity index 77% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/AuthFormContainer/AuthFormContainer.styles.tsx rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/AuthFormContainer/AuthFormContainer.styles.tsx index 6ef100c..c8f7dc8 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/AuthFormContainer/AuthFormContainer.styles.tsx +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/AuthFormContainer/AuthFormContainer.styles.tsx @@ -1,4 +1,4 @@ -import { styled } from '@workspace/ui'; +import { styled } from '@workspace/common/client/ui-kit'; export const AuthFormContainer = styled('div')(() => ({ display: 'flex', diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/AuthFormContainer/index.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/AuthFormContainer/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/AuthFormContainer/index.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/AuthFormContainer/index.ts diff --git a/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExample.tsx b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExample.tsx new file mode 100644 index 0000000..6b81ea0 --- /dev/null +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExample.tsx @@ -0,0 +1,25 @@ +import { useState } from 'react'; + +import { ExampleAuth, ExampleBody, ExampleFrame } from '@workspace/common/client/example/components'; + +import { CurrentExampleRoute, DefaultExampleRouter } from './DefaultExampleRouter'; +import { DefaultExampleTopBar } from './DefaultExampleTopBar'; +import { exampleRoutes } from './routes'; + +export const DefaultExample = () => { + const [expanded, setExpanded] = useState(true); + + return ( + + + + + + + + + + + + ); +}; diff --git a/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleRouter/DefaultExampleRouter.tsx b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleRouter/DefaultExampleRouter.tsx new file mode 100644 index 0000000..3d7b6f0 --- /dev/null +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleRouter/DefaultExampleRouter.tsx @@ -0,0 +1,27 @@ +import type { ReactNode } from 'react'; + +import { createExampleRouter, useExampleAuthSession } from '@workspace/common/client/example/components'; + +import type { ExampleRoutes } from '../routes'; + +const { ExampleRouter, useExampleRouter, CurrentExampleRoute } = createExampleRouter(); + +export interface DefaultExampleRouterProps { + children: ReactNode; + routes: ExampleRoutes; +} + +/** + * Yes, this not so smart solution but it's just an example, so please focus on the WebAutn part. Thanks. + */ +export const DefaultExampleRouter = ({ children, routes }: DefaultExampleRouterProps) => { + const { session } = useExampleAuthSession(); + + return ( + + {children} + + ); +}; + +export { CurrentExampleRoute, useExampleRouter }; diff --git a/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleRouter/index.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleRouter/index.ts new file mode 100644 index 0000000..52f6941 --- /dev/null +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleRouter/index.ts @@ -0,0 +1 @@ +export * from './DefaultExampleRouter'; diff --git a/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleTopBar/DefaultExampleTopBar.tsx b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleTopBar/DefaultExampleTopBar.tsx new file mode 100644 index 0000000..caf0833 --- /dev/null +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleTopBar/DefaultExampleTopBar.tsx @@ -0,0 +1,22 @@ +import { ExampleTopBar, type ExampleTopBarProps } from '@workspace/common/client/example/components'; + +import { useExampleRouter } from '../DefaultExampleRouter'; +import { useExampleRouteTitle } from './hooks/useExampleRouteTitle'; + +export interface DefaultExampleTopBarProps extends Pick {} + +export const DefaultExampleTopBar = ({ expanded, onToggleExpand }: DefaultExampleTopBarProps) => { + const title = useExampleRouteTitle(); + const { redirect } = useExampleRouter(); + + return ( + { + redirect('/login'); + }} + /> + ); +}; diff --git a/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleTopBar/hooks/useExampleRouteTitle.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleTopBar/hooks/useExampleRouteTitle.ts new file mode 100644 index 0000000..fb8ec07 --- /dev/null +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleTopBar/hooks/useExampleRouteTitle.ts @@ -0,0 +1,21 @@ +import { useExampleAuthSession } from '@workspace/common/client/example/components'; + +import { useExampleRouter } from '../../DefaultExampleRouter'; +import type { ExampleRoute } from '../../routes'; + +const routeTitles = { + '/passkeys': 'Registered passkeys', + '/register': 'Demo Registration', + '/login': 'Demo Login', +} as const satisfies Record; + +export function useExampleRouteTitle() { + const { session } = useExampleAuthSession(); + const { currentRoute } = useExampleRouter(); + + if (session.state === 'loading') { + return 'Loading...'; + } + + return routeTitles[currentRoute]; +} diff --git a/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleTopBar/index.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleTopBar/index.ts new file mode 100644 index 0000000..6670f03 --- /dev/null +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/DefaultExampleTopBar/index.ts @@ -0,0 +1 @@ +export * from './DefaultExampleTopBar'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/LoginWithPasskey.tsx b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/LoginWithPasskey.tsx similarity index 86% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/LoginWithPasskey.tsx rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/LoginWithPasskey.tsx index 79533ac..e3d7c34 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/LoginWithPasskey.tsx +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/LoginWithPasskey.tsx @@ -1,13 +1,13 @@ import Link from 'next/link'; -import { Alert, Box, Button, Divider, FieldsStack, FormError, Words } from '@workspace/ui'; -import { Fingerprint, InfoOutlined } from '@workspace/ui/icons'; - -import { queryClient } from '~modules/api/components'; -import { EmailField, Form, SubmitButton } from '~modules/form/components'; +import { queryClient } from '@workspace/common/client/api/components'; +import { EmailField, Form, FormError, SubmitButton } from '@workspace/common/client/form/components'; +import { FieldsStack } from '@workspace/common/client/form/components/'; +import { Alert, Box, Button, Divider, Words } from '@workspace/common/client/ui-kit'; +import { Fingerprint, InfoOutlined } from '@workspace/common/client/ui-kit/icons'; import { AuthFormContainer } from '../AuthFormContainer'; -import { useExampleRouter } from '../ExampleRouter'; +import { useExampleRouter } from '../DefaultExampleRouter'; import { useConditionalMediation } from './hooks/useConditionalMediation'; import { useLoginWithPasskey } from './hooks/useLoginWithPasskey'; import { loginFormSchema, type LoginFormSchema, type LoginFormValues } from './schema'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/hooks/useConditionalMediation.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/hooks/useConditionalMediation.ts similarity index 68% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/hooks/useConditionalMediation.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/hooks/useConditionalMediation.ts index fd91aef..1ed8c90 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/hooks/useConditionalMediation.ts +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/hooks/useConditionalMediation.ts @@ -2,18 +2,16 @@ import { browserSupportsWebAuthnAutofill, startAuthentication } from '@simpleweb import { useQuery } from '@tanstack/react-query'; import { signInWithCustomToken } from 'firebase/auth'; -import { logger } from '~logger'; -import { fetcher } from '~modules/api/fetcher'; -import { auth } from '~modules/firebase/config'; -import { parseWebAuthnError } from '~modules/passkeys/utils'; -import { useSnack } from '~modules/snackbar/hooks'; -import type { StartLoginResponseData } from '~pages/api/authentication/with-firebase/login/options'; -import type { - VerifyLoginRequestData, - VerifyLoginResponseData, -} from '~pages/api/authentication/with-firebase/login/verify'; - -import { useExampleRouter } from '../../ExampleRouter'; +import { fetcher } from '@workspace/common/client/api/fetcher'; +import { auth } from '@workspace/common/client/firebase/config'; +import { useSnack } from '@workspace/common/client/snackbar/hooks'; +import { parseWebAuthnError } from '@workspace/common/client/webauthn/utils'; +import { logger } from '@workspace/common/logger'; + +import type { StartLoginResponseData } from '~pages/api/webauthn/login/options'; +import type { VerifyLoginRequestData, VerifyLoginResponseData } from '~pages/api/webauthn/login/verify'; + +import { useExampleRouter } from '../../DefaultExampleRouter'; export function useConditionalMediation() { const { redirect } = useExampleRouter(); @@ -33,10 +31,10 @@ export function useConditionalMediation() { data: { publicKeyOptions }, } = await fetcher({ method: 'GET', - url: '/authentication/with-firebase/login/options', + url: '/webauthn/login/options', }); - logger.info('/authentication/with-firebase/login/options', publicKeyOptions); + logger.info('/webauthn/login/options', publicKeyOptions); const result = await startAuthentication({ optionsJSON: publicKeyOptions, @@ -47,13 +45,13 @@ export function useConditionalMediation() { const { data } = await fetcher({ method: 'POST', - url: '/authentication/with-firebase/login/verify', + url: '/webauthn/login/verify', body: { authenticationResponse: result, } satisfies VerifyLoginRequestData, }); - logger.info('/authentication/with-firebase/login/verify', data); + logger.info('/webauthn/login/verify', data); const userCredential = await signInWithCustomToken(auth(), data.customToken); diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/hooks/useLoginWithPasskey.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/hooks/useLoginWithPasskey.ts similarity index 63% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/hooks/useLoginWithPasskey.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/hooks/useLoginWithPasskey.ts index 3420c7f..a615a3f 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/hooks/useLoginWithPasskey.ts +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/hooks/useLoginWithPasskey.ts @@ -1,21 +1,16 @@ import { startAuthentication } from '@simplewebauthn/browser'; import { signInWithCustomToken } from 'firebase/auth'; -import { logger } from '~logger'; -import { fetcher } from '~modules/api/fetcher'; -import { auth } from '~modules/firebase/config'; -import type { FormProps } from '~modules/form/components'; -import { parseWebAuthnError } from '~modules/passkeys/utils'; -import type { - StartLoginRequestData, - StartLoginResponseData, -} from '~pages/api/authentication/with-firebase/login/options'; -import type { - VerifyLoginRequestData, - VerifyLoginResponseData, -} from '~pages/api/authentication/with-firebase/login/verify'; +import { fetcher } from '@workspace/common/client/api/fetcher'; +import { auth } from '@workspace/common/client/firebase/config'; +import type { FormProps } from '@workspace/common/client/form/components'; +import { parseWebAuthnError } from '@workspace/common/client/webauthn/utils'; +import { logger } from '@workspace/common/logger'; -import { useExampleRouter } from '../../ExampleRouter'; +import type { StartLoginRequestData, StartLoginResponseData } from '~pages/api/webauthn/login/options'; +import type { VerifyLoginRequestData, VerifyLoginResponseData } from '~pages/api/webauthn/login/verify'; + +import { useExampleRouter } from '../../DefaultExampleRouter'; import type { LoginFormSchema, LoginFormValues } from '../schema'; export function useLoginWithPasskey(): FormProps['onSubmit'] { @@ -27,11 +22,11 @@ export function useLoginWithPasskey(): FormProps({ method: 'POST', - url: '/authentication/with-firebase/login/options', + url: '/webauthn/login/options', body: { username } satisfies StartLoginRequestData, }); - logger.info('/authentication/with-firebase/login/options', { publicKeyOptions }); + logger.info('/webauthn/login/options', { publicKeyOptions }); const result = await startAuthentication({ optionsJSON: publicKeyOptions, @@ -41,13 +36,13 @@ export function useLoginWithPasskey(): FormProps({ method: 'POST', - url: '/authentication/with-firebase/login/verify', + url: '/webauthn/login/verify', body: { authenticationResponse: result, } satisfies VerifyLoginRequestData, }); - logger.info('/authentication/with-firebase/login/verify', { data }); + logger.info('/webauthn/login/verify', { data }); await signInWithCustomToken(auth(), data.customToken); diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/index.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/index.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/schema/index.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/schema/index.ts similarity index 76% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/schema/index.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/schema/index.ts index 0d30836..8187ef5 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/LoginWithPasskey/schema/index.ts +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/LoginWithPasskey/schema/index.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import { email } from '~modules/form/validators'; +import { email } from '@workspace/common/client/form/validators'; export const loginFormSchema = z.object({ email: email.optional(), diff --git a/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/Passkeys.styles.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/Passkeys.styles.ts new file mode 100644 index 0000000..ad90790 --- /dev/null +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/Passkeys.styles.ts @@ -0,0 +1,15 @@ +import { styled } from '@workspace/common/client/ui-kit'; + +export const PasskeysHeader = styled('header')(({ theme }) => ({ + marginBottom: theme.spacing(2), + marginTop: theme.spacing(2), + display: 'grid', + justifyContent: 'space-between', + alignItems: 'center', + gridTemplateColumns: 'auto auto', +})); + +export const PasskeysList = styled('section')(({ theme }) => ({ + display: 'grid', + rowGap: theme.spacing(3.5), +})); diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkeys.tsx b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/Passkeys.tsx similarity index 85% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkeys.tsx rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/Passkeys.tsx index 7c5e01d..bafdbfa 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkeys.tsx +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/Passkeys.tsx @@ -1,13 +1,12 @@ -import { Button, Words } from '@workspace/ui'; -import { Fingerprint } from '@workspace/ui/icons'; - -import { useDialog } from '~hooks'; -import { QueryError, QueryLoader } from '~modules/api/components'; +import { QueryError, QueryLoader } from '@workspace/common/client/api/components'; +import { useDialog } from '@workspace/common/client/dialog/hooks'; +import { Passkey } from '@workspace/common/client/passkeys/components'; +import { Button, Words } from '@workspace/common/client/ui-kit'; +import { Fingerprint } from '@workspace/common/client/ui-kit/icons'; import { useAddPasskey } from './hooks/useAddPasskey'; import { useFetchPasskeys } from './hooks/useFetchPasskeys'; import { useRemovePasskey } from './hooks/useRemovePasskey'; -import { Passkey } from './Passkey'; import { PasskeysHeader, PasskeysList } from './Passkeys.styles'; import { PostRemovalDialog, type PostRemovalDialogProps } from './PostRemovalDialog'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/PostRemovalDialog/PostRemovalDialog.styles.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/PostRemovalDialog/PostRemovalDialog.styles.ts similarity index 82% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/PostRemovalDialog/PostRemovalDialog.styles.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/PostRemovalDialog/PostRemovalDialog.styles.ts index 42f5258..14403f3 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/PostRemovalDialog/PostRemovalDialog.styles.ts +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/PostRemovalDialog/PostRemovalDialog.styles.ts @@ -1,4 +1,4 @@ -import { styled } from '@workspace/ui'; +import { styled } from '@workspace/common/client/ui-kit'; export const PasskeyDetails = styled('div')(({ theme }) => ({ display: 'grid', diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/PostRemovalDialog/PostRemovalDialog.tsx b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/PostRemovalDialog/PostRemovalDialog.tsx similarity index 84% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/PostRemovalDialog/PostRemovalDialog.tsx rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/PostRemovalDialog/PostRemovalDialog.tsx index eff1be3..61e658a 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/PostRemovalDialog/PostRemovalDialog.tsx +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/PostRemovalDialog/PostRemovalDialog.tsx @@ -1,10 +1,9 @@ -import { Box, Button, Dialog, DialogActions, Icon, Stack, Words } from '@workspace/ui'; -import { Warning } from '@workspace/ui/icons'; +import { Caption } from '@workspace/common/client/passkeys/components/Passkey/Caption'; +import { ProviderProfile } from '@workspace/common/client/passkeys/components/Passkey/ProviderProfile'; +import { Box, Button, Dialog, DialogActions, Icon, Stack, Words } from '@workspace/common/client/ui-kit'; +import { Warning } from '@workspace/common/client/ui-kit/icons'; +import type { Passkey } from '@workspace/common/types'; -import type { Passkey } from '~server/types'; - -import { Caption } from '../Passkey/Caption'; -import { ProviderProfile } from '../Passkey/ProviderProfile'; import { PasskeyDetails } from './PostRemovalDialog.styles'; export interface PostRemovalDialogProps { diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/PostRemovalDialog/index.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/PostRemovalDialog/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/PostRemovalDialog/index.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/PostRemovalDialog/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/hooks/useAddPasskey.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/hooks/useAddPasskey.ts similarity index 67% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/hooks/useAddPasskey.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/hooks/useAddPasskey.ts index 1605e97..8356a96 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/hooks/useAddPasskey.ts +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/hooks/useAddPasskey.ts @@ -1,11 +1,12 @@ import { startRegistration } from '@simplewebauthn/browser'; import { useMutation } from '@tanstack/react-query'; -import { logger } from '~logger'; -import { queryClient } from '~modules/api/components'; -import { fetcher } from '~modules/api/fetcher'; -import { useSnack } from '~modules/snackbar/hooks'; -import type { StartLinkingResponseData } from '~pages/api/authentication/with-firebase/link/options'; +import { queryClient } from '@workspace/common/client/api/components'; +import { fetcher } from '@workspace/common/client/api/fetcher'; +import { useSnack } from '@workspace/common/client/snackbar/hooks'; +import { logger } from '@workspace/common/logger'; + +import type { StartLinkingResponseData } from '~pages/api/webauthn/link/options'; export function useAddPasskey() { const snack = useSnack(); @@ -16,10 +17,10 @@ export function useAddPasskey() { data: { publicKeyOptions }, } = await fetcher({ method: 'GET', - url: '/authentication/with-firebase/link/options', + url: '/webauthn/link/options', }); - logger.info('/authentication/with-firebase/link/options', publicKeyOptions); + logger.info('/webauthn/link/options', publicKeyOptions); const result = await startRegistration({ optionsJSON: publicKeyOptions, @@ -29,7 +30,7 @@ export function useAddPasskey() { await fetcher({ method: 'POST', - url: '/authentication/with-firebase/link/verify', + url: '/webauthn/link/verify', body: { registrationResponse: result, }, diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/hooks/useFetchPasskeys.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/hooks/useFetchPasskeys.ts similarity index 66% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/hooks/useFetchPasskeys.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/hooks/useFetchPasskeys.ts index bf8d00c..5e1a299 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/hooks/useFetchPasskeys.ts +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/hooks/useFetchPasskeys.ts @@ -1,8 +1,7 @@ import { useQuery } from '@tanstack/react-query'; -import { getPasskeys } from '~modules/firebase/services/passkeys'; - -import { useAuthUser } from '../../ExampleAuth'; +import { useAuthUser } from '@workspace/common/client/example/components'; +import { getPasskeys } from '@workspace/common/server/services/passkeys'; export function useFetchPasskeys() { const authUser = useAuthUser(); diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/hooks/useRemovePasskey.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/hooks/useRemovePasskey.ts similarity index 70% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/hooks/useRemovePasskey.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/hooks/useRemovePasskey.ts index 750335f..81feda2 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/hooks/useRemovePasskey.ts +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/hooks/useRemovePasskey.ts @@ -1,15 +1,16 @@ import { startAuthentication } from '@simplewebauthn/browser'; import { useMutation } from '@tanstack/react-query'; -import { logger } from '~logger'; -import { queryClient } from '~modules/api/components'; -import { fetcher } from '~modules/api/fetcher'; -import { useSnack } from '~modules/snackbar/hooks'; -import type { StartRemovalResponseData } from '~pages/api/authentication/with-firebase/remove/options'; -import type { VerifyRemovalRequestData } from '~pages/api/authentication/with-firebase/remove/verify'; -import type { Passkey } from '~server/types'; +import { queryClient } from '@workspace/common/client/api/components'; +import { fetcher } from '@workspace/common/client/api/fetcher'; +import { useAuthUser } from '@workspace/common/client/example/components'; +import { useSnack } from '@workspace/common/client/snackbar/hooks'; +import { logger } from '@workspace/common/logger'; +import type { Passkey } from '@workspace/common/types'; + +import type { StartRemovalResponseData } from '~pages/api/webauthn/remove/options'; +import type { VerifyRemovalRequestData } from '~pages/api/webauthn/remove/verify'; -import { useAuthUser } from '../../ExampleAuth'; import type { PostRemovalDialogProps } from '../PostRemovalDialog'; /** @@ -26,10 +27,10 @@ export function useRemovePasskey(openDialog: (data: PostRemovalDialogProps['data data: { publicKeyOptions }, } = await fetcher({ method: 'GET', - url: '/authentication/with-firebase/remove/options', + url: '/webauthn/remove/options', }); - logger.info('/authentication/with-firebase/remove/options', publicKeyOptions); + logger.info('/webauthn/remove/options', publicKeyOptions); const result = await startAuthentication({ optionsJSON: publicKeyOptions, @@ -39,7 +40,7 @@ export function useRemovePasskey(openDialog: (data: PostRemovalDialogProps['data const { data: passkey } = await fetcher({ method: 'POST', - url: '/authentication/with-firebase/remove/verify', + url: '/webauthn/remove/verify', body: { authenticationResponse: result, passkeyId, diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/index.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/index.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/Passkeys/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/RegisterWithPasskey.tsx b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/RegisterWithPasskey.tsx similarity index 82% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/RegisterWithPasskey.tsx rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/RegisterWithPasskey.tsx index a567e0f..ab3df46 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/RegisterWithPasskey.tsx +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/RegisterWithPasskey.tsx @@ -1,10 +1,9 @@ -import { Box, Button, Divider, FieldsStack, FormError, Words } from '@workspace/ui'; -import { Fingerprint } from '@workspace/ui/icons'; - -import { EmailField, Form, SubmitButton } from '~modules/form/components'; +import { EmailField, FieldsStack, Form, FormError, SubmitButton } from '@workspace/common/client/form/components'; +import { Box, Button, Divider, Words } from '@workspace/common/client/ui-kit'; +import { Fingerprint } from '@workspace/common/client/ui-kit/icons'; import { AuthFormContainer } from '../AuthFormContainer'; -import { useExampleRouter } from '../ExampleRouter'; +import { useExampleRouter } from '../DefaultExampleRouter'; import { useRegisterWithPasskey } from './hooks'; import { registerFormSchema, type RegisterFormSchema, type RegisterFormValues } from './schema'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/hooks/index.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/hooks/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/hooks/index.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/hooks/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/hooks/useRegisterWithPasskey.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/hooks/useRegisterWithPasskey.ts similarity index 66% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/hooks/useRegisterWithPasskey.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/hooks/useRegisterWithPasskey.ts index a33f503..a0acd4d 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/hooks/useRegisterWithPasskey.ts +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/hooks/useRegisterWithPasskey.ts @@ -1,21 +1,19 @@ import { startRegistration } from '@simplewebauthn/browser'; import { signInWithCustomToken } from 'firebase/auth'; -import { logger } from '~logger'; -import { fetcher } from '~modules/api/fetcher'; -import { auth } from '~modules/firebase/config'; -import type { FormProps } from '~modules/form/components'; -import { parseWebAuthnError } from '~modules/passkeys/utils'; -import type { - StartRegistrationRequestData, - StartRegistrationResponseData, -} from '~pages/api/authentication/with-firebase/register/options'; +import { fetcher } from '@workspace/common/client/api/fetcher'; +import { auth } from '@workspace/common/client/firebase/config'; +import type { FormProps } from '@workspace/common/client/form/components'; +import { parseWebAuthnError } from '@workspace/common/client/webauthn/utils'; +import { logger } from '@workspace/common/logger'; + +import type { StartRegistrationRequestData, StartRegistrationResponseData } from '~pages/api/webauthn/register/options'; import type { VerifyRegistrationRequestData, VerifyRegistrationResponseData, -} from '~pages/api/authentication/with-firebase/register/verify'; +} from '~pages/api/webauthn/register/verify'; -import { useExampleRouter } from '../../ExampleRouter'; +import { useExampleRouter } from '../../DefaultExampleRouter'; import type { RegisterFormSchema, RegisterFormValues } from '../schema'; export function useRegisterWithPasskey(): FormProps['onSubmit'] { @@ -27,11 +25,11 @@ export function useRegisterWithPasskey(): FormProps({ method: 'POST', - url: '/authentication/with-firebase/register/options', + url: '/webauthn/register/options', body: { username } satisfies StartRegistrationRequestData, }); - logger.info('/authentication/with-firebase/register/options', { publicKeyOptions, username }); + logger.info('/webauthn/register/options', { publicKeyOptions, username }); const result = await startRegistration({ optionsJSON: publicKeyOptions, @@ -41,13 +39,13 @@ export function useRegisterWithPasskey(): FormProps({ method: 'POST', - url: '/authentication/with-firebase/register/verify', + url: '/webauthn/register/verify', body: { registrationResponse: result, } satisfies VerifyRegistrationRequestData, }); - logger.info('/authentication/with-firebase/register/verify', { data }); + logger.info('/webauthn/register/verify', { data }); await signInWithCustomToken(auth(), data.customToken); diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/index.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/index.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/schema/index.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/schema/index.ts similarity index 76% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/schema/index.ts rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/schema/index.ts index fe29304..10cbcd5 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/RegisterWithPasskey/schema/index.ts +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/RegisterWithPasskey/schema/index.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import { email } from '~modules/form/validators'; +import { email } from '@workspace/common/client/form/validators'; export const registerFormSchema = z.object({ email, diff --git a/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/index.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/index.ts new file mode 100644 index 0000000..8a4749d --- /dev/null +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/index.ts @@ -0,0 +1 @@ +export * from './DefaultExample'; diff --git a/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/routes/index.tsx b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/routes/index.tsx new file mode 100644 index 0000000..fca83ab --- /dev/null +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/DefaultExample/routes/index.tsx @@ -0,0 +1,14 @@ +import type { UnknownRoutes } from '@workspace/common/client/example/components'; + +import { LoginWithPasskey } from '../LoginWithPasskey'; +import { Passkeys } from '../Passkeys'; +import { RegisterWithPasskey } from '../RegisterWithPasskey'; + +export const exampleRoutes = { + '/register': () => , + '/login': () => , + '/passkeys': () => , +} as const satisfies UnknownRoutes; + +export type ExampleRoutes = typeof exampleRoutes; +export type ExampleRoute = keyof ExampleRoutes; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/PasskeysWithFirebasePage.tsx b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/WebAuthnDefaultExamplePage.tsx similarity index 79% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/PasskeysWithFirebasePage.tsx rename to examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/WebAuthnDefaultExamplePage.tsx index bbbb56f..40b32de 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/PasskeysWithFirebasePage.tsx +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/WebAuthnDefaultExamplePage.tsx @@ -1,13 +1,12 @@ import Link from 'next/link'; -import { Container, ExampleDescription, ExampleHeader } from '@workspace/ui'; +import { ExampleDescription, ExampleHeader, ExampleWrapper } from '@workspace/common/client/example/components'; +import { MainHeader } from '@workspace/common/client/layout/components'; +import { Container } from '@workspace/common/client/ui-kit'; -import { MainHeader } from '~modules/layout/components'; +import { DefaultExample } from './DefaultExample'; -import { FirebaseExample } from './FirebaseExample'; -import { ExampleWrapper } from './PasskeysWithFirebasePage.styles'; - -export const PasskeysWithFirebasePage = () => { +export const WebAuthnDefaultExamplePage = () => { return ( <> @@ -34,7 +33,7 @@ export const PasskeysWithFirebasePage = () => { /> } /> - + diff --git a/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/index.ts b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/index.ts new file mode 100644 index 0000000..ffc23fe --- /dev/null +++ b/examples/webauthn-default/src/components/WebAuthnDefaultExamplePage/index.ts @@ -0,0 +1 @@ +export * from './WebAuthnDefaultExamplePage'; diff --git a/examples/simplewebauthn/src/instrumentation.ts b/examples/webauthn-default/src/instrumentation.ts similarity index 100% rename from examples/simplewebauthn/src/instrumentation.ts rename to examples/webauthn-default/src/instrumentation.ts diff --git a/examples/webauthn-default/src/pages/_app.tsx b/examples/webauthn-default/src/pages/_app.tsx new file mode 100755 index 0000000..f7ebc4e --- /dev/null +++ b/examples/webauthn-default/src/pages/_app.tsx @@ -0,0 +1,3 @@ +import { App } from '@workspace/common/client/core/components'; + +export default App; diff --git a/examples/webauthn-default/src/pages/_document.tsx b/examples/webauthn-default/src/pages/_document.tsx new file mode 100644 index 0000000..30166d9 --- /dev/null +++ b/examples/webauthn-default/src/pages/_document.tsx @@ -0,0 +1,3 @@ +import { MyDocument } from '@workspace/common/client/core/components'; + +export default MyDocument; diff --git a/examples/webauthn-default/src/pages/_error.jsx b/examples/webauthn-default/src/pages/_error.jsx new file mode 100644 index 0000000..df405cb --- /dev/null +++ b/examples/webauthn-default/src/pages/_error.jsx @@ -0,0 +1,3 @@ +import { CustomError } from '@workspace/common/client/core/components'; + +export default CustomError; diff --git a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/link/options.ts b/examples/webauthn-default/src/pages/api/webauthn/link/options.ts similarity index 87% rename from examples/simplewebauthn/src/pages/api/authentication/with-firebase/link/options.ts rename to examples/webauthn-default/src/pages/api/webauthn/link/options.ts index 1d33139..da8fc49 100644 --- a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/link/options.ts +++ b/examples/webauthn-default/src/pages/api/webauthn/link/options.ts @@ -3,14 +3,13 @@ import { generateRegistrationOptions } from '@simplewebauthn/server'; import { generateChallenge } from '@simplewebauthn/server/helpers'; import type { PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types'; -import { env } from '~env'; -import { logger } from '~logger'; -import { RP_NAME } from '~server/constants/relyingParty'; -import { initializeChallengeSession } from '~server/services/challenge-session'; -import { getPasskeys } from '~server/services/passkeys'; -import { getUser } from '~server/services/users'; -import { parseAndVerifyIdToken } from '~server/utils/parseAndVerifyIdToken'; -import { getRpId } from '~server/utils/relyingParty'; +import { env } from '@workspace/common/client/env'; +import { logger } from '@workspace/common/logger'; +import { RP_NAME } from '@workspace/common/server/constants/relyingParty'; +import { initializeChallengeSession } from '@workspace/common/server/services/challenge-session'; +import { getPasskeys } from '@workspace/common/server/services/passkeys'; +import { getUser } from '@workspace/common/server/services/users'; +import { getRpId, parseAndVerifyIdToken } from '@workspace/common/server/utils'; export type StartLinkingResponseData = { publicKeyOptions: PublicKeyCredentialCreationOptionsJSON; diff --git a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/link/verify.ts b/examples/webauthn-default/src/pages/api/webauthn/link/verify.ts similarity index 84% rename from examples/simplewebauthn/src/pages/api/authentication/with-firebase/link/verify.ts rename to examples/webauthn-default/src/pages/api/webauthn/link/verify.ts index 14e643d..817fd07 100644 --- a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/link/verify.ts +++ b/examples/webauthn-default/src/pages/api/webauthn/link/verify.ts @@ -2,11 +2,11 @@ import type { NextApiRequest, NextApiResponse } from 'next'; import { verifyRegistrationResponse } from '@simplewebauthn/server'; import type { RegistrationResponseJSON } from '@simplewebauthn/types'; -import { env } from '~env'; -import { logger } from '~logger'; -import { retrieveAndInvalidateChallengeSession } from '~server/services/challenge-session'; -import { addUserPasskey } from '~server/services/users'; -import { parseAndVerifyIdToken } from '~server/utils/parseAndVerifyIdToken'; +import { env } from '@workspace/common/client/env'; +import { logger } from '@workspace/common/logger'; +import { retrieveAndInvalidateChallengeSession } from '@workspace/common/server/services/challenge-session'; +import { addUserPasskey } from '@workspace/common/server/services/users'; +import { parseAndVerifyIdToken } from '@workspace/common/server/utils'; export type VerifyLinkRequestData = { registrationResponse: RegistrationResponseJSON; diff --git a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/login/options.ts b/examples/webauthn-default/src/pages/api/webauthn/login/options.ts similarity index 89% rename from examples/simplewebauthn/src/pages/api/authentication/with-firebase/login/options.ts rename to examples/webauthn-default/src/pages/api/webauthn/login/options.ts index 314fec5..ebcd319 100644 --- a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/login/options.ts +++ b/examples/webauthn-default/src/pages/api/webauthn/login/options.ts @@ -4,11 +4,11 @@ import { generateChallenge } from '@simplewebauthn/server/helpers'; import type { PublicKeyCredentialRequestOptionsJSON } from '@simplewebauthn/types'; import { z } from 'zod'; -import { env } from '~env'; -import { logger } from '~logger'; -import { initializeChallengeSession } from '~server/services/challenge-session'; -import { getUserPasskeys } from '~server/services/users'; -import { getRpId } from '~server/utils/relyingParty'; +import { env } from '@workspace/common/client/env'; +import { logger } from '@workspace/common/logger'; +import { initializeChallengeSession } from '@workspace/common/server/services/challenge-session'; +import { getUserPasskeys } from '@workspace/common/server/services/users'; +import { getRpId } from '@workspace/common/server/utils'; export const startAuthenticationRequestBody = z.object({ /** diff --git a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/login/verify.ts b/examples/webauthn-default/src/pages/api/webauthn/login/verify.ts similarity index 89% rename from examples/simplewebauthn/src/pages/api/authentication/with-firebase/login/verify.ts rename to examples/webauthn-default/src/pages/api/webauthn/login/verify.ts index d0105bb..c7bde83 100644 --- a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/login/verify.ts +++ b/examples/webauthn-default/src/pages/api/webauthn/login/verify.ts @@ -4,11 +4,11 @@ import { verifyAuthenticationResponse } from '@simplewebauthn/server'; import type { AuthenticationResponseJSON } from '@simplewebauthn/types'; import { FieldValue } from 'firebase-admin/firestore'; -import { env } from '~env'; -import { logger } from '~logger'; -import { createCustomToken } from '~server/services/auth'; -import { retrieveAndInvalidateChallengeSession } from '~server/services/challenge-session'; -import { getPasskeyBy, updatePasskey } from '~server/services/passkeys'; +import { env } from '@workspace/common/client/env'; +import { logger } from '@workspace/common/logger'; +import { createCustomToken } from '@workspace/common/server/services/auth'; +import { retrieveAndInvalidateChallengeSession } from '@workspace/common/server/services/challenge-session'; +import { getPasskeyBy, updatePasskey } from '@workspace/common/server/services/passkeys'; export type VerifyLoginRequestData = { authenticationResponse: AuthenticationResponseJSON; diff --git a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/register/options.ts b/examples/webauthn-default/src/pages/api/webauthn/register/options.ts similarity index 88% rename from examples/simplewebauthn/src/pages/api/authentication/with-firebase/register/options.ts rename to examples/webauthn-default/src/pages/api/webauthn/register/options.ts index 51a4073..324671c 100644 --- a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/register/options.ts +++ b/examples/webauthn-default/src/pages/api/webauthn/register/options.ts @@ -4,12 +4,12 @@ import { generateChallenge } from '@simplewebauthn/server/helpers'; import type { PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types'; import { z } from 'zod'; -import { env } from '~env'; -import { logger } from '~logger'; -import { RP_NAME } from '~server/constants/relyingParty'; -import { initializeChallengeSession } from '~server/services/challenge-session'; -import { getUserPasskeys } from '~server/services/users'; -import { getRpId } from '~server/utils/relyingParty'; +import { env } from '@workspace/common/client/env'; +import { logger } from '@workspace/common/logger'; +import { RP_NAME } from '@workspace/common/server/constants/relyingParty'; +import { initializeChallengeSession } from '@workspace/common/server/services/challenge-session'; +import { getUserPasskeys } from '@workspace/common/server/services/users'; +import { getRpId } from '@workspace/common/server/utils'; const startRegistrationRequestBody = z.object({ username: z.string(), diff --git a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/register/verify.ts b/examples/webauthn-default/src/pages/api/webauthn/register/verify.ts similarity index 86% rename from examples/simplewebauthn/src/pages/api/authentication/with-firebase/register/verify.ts rename to examples/webauthn-default/src/pages/api/webauthn/register/verify.ts index 8b37a2c..9bdadec 100644 --- a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/register/verify.ts +++ b/examples/webauthn-default/src/pages/api/webauthn/register/verify.ts @@ -2,11 +2,11 @@ import type { NextApiRequest, NextApiResponse } from 'next'; import { verifyRegistrationResponse } from '@simplewebauthn/server'; import type { RegistrationResponseJSON } from '@simplewebauthn/types'; -import { env } from '~env'; -import { logger } from '~logger'; -import { createCustomToken } from '~server/services/auth'; -import { retrieveAndInvalidateChallengeSession } from '~server/services/challenge-session'; -import { createUserPasskey, findUserByUsername } from '~server/services/users'; +import { env } from '@workspace/common/client/env'; +import { logger } from '@workspace/common/logger'; +import { createCustomToken } from '@workspace/common/server/services/auth'; +import { retrieveAndInvalidateChallengeSession } from '@workspace/common/server/services/challenge-session'; +import { createUserPasskey, findUserByUsername } from '@workspace/common/server/services/users'; export type VerifyRegistrationRequestData = { registrationResponse: RegistrationResponseJSON; diff --git a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/remove/options.ts b/examples/webauthn-default/src/pages/api/webauthn/remove/options.ts similarity index 86% rename from examples/simplewebauthn/src/pages/api/authentication/with-firebase/remove/options.ts rename to examples/webauthn-default/src/pages/api/webauthn/remove/options.ts index f312e3e..ea71de1 100644 --- a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/remove/options.ts +++ b/examples/webauthn-default/src/pages/api/webauthn/remove/options.ts @@ -3,12 +3,11 @@ import { generateAuthenticationOptions } from '@simplewebauthn/server'; import { generateChallenge } from '@simplewebauthn/server/helpers'; import type { PublicKeyCredentialCreationOptionsJSON } from '@simplewebauthn/types'; -import { env } from '~env'; -import { logger } from '~logger'; -import { initializeChallengeSession } from '~server/services/challenge-session'; -import { getPasskeys } from '~server/services/passkeys'; -import { parseAndVerifyIdToken } from '~server/utils/parseAndVerifyIdToken'; -import { getRpId } from '~server/utils/relyingParty'; +import { env } from '@workspace/common/client/env'; +import { logger } from '@workspace/common/logger'; +import { initializeChallengeSession } from '@workspace/common/server/services/challenge-session'; +import { getPasskeys } from '@workspace/common/server/services/passkeys'; +import { getRpId, parseAndVerifyIdToken } from '@workspace/common/server/utils'; export type StartRemovalResponseData = { publicKeyOptions: PublicKeyCredentialCreationOptionsJSON; diff --git a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/remove/verify.ts b/examples/webauthn-default/src/pages/api/webauthn/remove/verify.ts similarity index 84% rename from examples/simplewebauthn/src/pages/api/authentication/with-firebase/remove/verify.ts rename to examples/webauthn-default/src/pages/api/webauthn/remove/verify.ts index 3cebdff..dea17fa 100644 --- a/examples/simplewebauthn/src/pages/api/authentication/with-firebase/remove/verify.ts +++ b/examples/webauthn-default/src/pages/api/webauthn/remove/verify.ts @@ -3,13 +3,13 @@ import { base64URLStringToBuffer } from '@simplewebauthn/browser'; import { verifyAuthenticationResponse } from '@simplewebauthn/server'; import type { AuthenticationResponseJSON } from '@simplewebauthn/types'; -import { env } from '~env'; -import { logger } from '~logger'; -import { retrieveAndInvalidateChallengeSession } from '~server/services/challenge-session'; -import { getPasskey, getPasskeyBy } from '~server/services/passkeys'; -import { removeUserPasskey } from '~server/services/users'; -import type { Passkey } from '~server/types'; -import { parseAndVerifyIdToken } from '~server/utils/parseAndVerifyIdToken'; +import { env } from '@workspace/common/client/env'; +import { logger } from '@workspace/common/logger'; +import { retrieveAndInvalidateChallengeSession } from '@workspace/common/server/services/challenge-session'; +import { getPasskey, getPasskeyBy } from '@workspace/common/server/services/passkeys'; +import { removeUserPasskey } from '@workspace/common/server/services/users'; +import { parseAndVerifyIdToken } from '@workspace/common/server/utils'; +import type { Passkey } from '@workspace/common/types'; export type VerifyRemovalRequestData = { authenticationResponse: AuthenticationResponseJSON; diff --git a/examples/webauthn-default/src/pages/index.tsx b/examples/webauthn-default/src/pages/index.tsx new file mode 100644 index 0000000..298ab9a --- /dev/null +++ b/examples/webauthn-default/src/pages/index.tsx @@ -0,0 +1,3 @@ +import { WebAuthnDefaultExamplePage } from '~components/WebAuthnDefaultExamplePage'; + +export default WebAuthnDefaultExamplePage; diff --git a/examples/webauthn-default/tsconfig.json b/examples/webauthn-default/tsconfig.json new file mode 100755 index 0000000..df24ec8 --- /dev/null +++ b/examples/webauthn-default/tsconfig.json @@ -0,0 +1,23 @@ +{ + "extends": "@tooling/typescript/nextjs", + "compilerOptions": { + "baseUrl": ".", + "jsx": "preserve", + "paths": { + "~*": [ + "./src/*", + ], + "@workspace/common/*": [ + "../../common/*", + ], + "~public/*": [ + "./public/*" + ], + } + }, + "include": [ + "**/*.ts", + "**/*.tsx", + "**/*.mts" + ] +} \ No newline at end of file diff --git a/packages/ui/.madgerc b/packages/common/.madgerc similarity index 100% rename from packages/ui/.madgerc rename to packages/common/.madgerc diff --git a/packages/common/README.md b/packages/common/README.md new file mode 100644 index 0000000..3f1464d --- /dev/null +++ b/packages/common/README.md @@ -0,0 +1,3 @@ +# Common code for WebAuthn examples + +This directory consists shared code for client and server side among WebAuthn demos (i.e. `/examples/*`). diff --git a/examples/simplewebauthn/src/modules/api/components/AppQueryProvider/AppQueryProvider.tsx b/packages/common/client/api/components/AppQueryProvider/AppQueryProvider.tsx similarity index 97% rename from examples/simplewebauthn/src/modules/api/components/AppQueryProvider/AppQueryProvider.tsx rename to packages/common/client/api/components/AppQueryProvider/AppQueryProvider.tsx index c688aa3..132f0bd 100644 --- a/examples/simplewebauthn/src/modules/api/components/AppQueryProvider/AppQueryProvider.tsx +++ b/packages/common/client/api/components/AppQueryProvider/AppQueryProvider.tsx @@ -1,7 +1,7 @@ import type { ReactNode } from 'react'; import { HydrationBoundary, MutationCache, QueryCache, QueryClient, QueryClientProvider } from '@tanstack/react-query'; -import { env } from '~env'; +import { env } from '~client/env'; import { logger } from '~logger'; export interface AppQueryProviderProps { diff --git a/examples/simplewebauthn/src/modules/api/components/AppQueryProvider/index.ts b/packages/common/client/api/components/AppQueryProvider/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/api/components/AppQueryProvider/index.ts rename to packages/common/client/api/components/AppQueryProvider/index.ts diff --git a/examples/simplewebauthn/src/modules/api/components/QueryError/QueryError.tsx b/packages/common/client/api/components/QueryError/QueryError.tsx similarity index 93% rename from examples/simplewebauthn/src/modules/api/components/QueryError/QueryError.tsx rename to packages/common/client/api/components/QueryError/QueryError.tsx index 06c9f5d..fb6126b 100644 --- a/examples/simplewebauthn/src/modules/api/components/QueryError/QueryError.tsx +++ b/packages/common/client/api/components/QueryError/QueryError.tsx @@ -1,7 +1,7 @@ import type { ReactNode } from 'react'; import type { UseQueryResult } from '@tanstack/react-query'; -import { Alert, type AlertProps } from '@workspace/ui'; +import { Alert, type AlertProps } from '~client/ui-kit'; import { RefetchButton } from '../RefetchButton'; diff --git a/examples/simplewebauthn/src/modules/api/components/QueryError/index.ts b/packages/common/client/api/components/QueryError/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/api/components/QueryError/index.ts rename to packages/common/client/api/components/QueryError/index.ts diff --git a/examples/simplewebauthn/src/modules/api/components/QueryLoader/QueryLoader.tsx b/packages/common/client/api/components/QueryLoader/QueryLoader.tsx similarity index 97% rename from examples/simplewebauthn/src/modules/api/components/QueryLoader/QueryLoader.tsx rename to packages/common/client/api/components/QueryLoader/QueryLoader.tsx index 8025aee..41df81b 100644 --- a/examples/simplewebauthn/src/modules/api/components/QueryLoader/QueryLoader.tsx +++ b/packages/common/client/api/components/QueryLoader/QueryLoader.tsx @@ -1,7 +1,7 @@ import type { ReactNode } from 'react'; import type { UseQueryResult } from '@tanstack/react-query'; -import { Loader, LoaderContainer, type LoaderContainerHeight } from '@workspace/ui'; +import { Loader, LoaderContainer, type LoaderContainerHeight } from '~client/ui-kit'; export interface QueryLoaderProps { children: ReactNode | ReactNode[]; diff --git a/examples/simplewebauthn/src/modules/api/components/QueryLoader/index.ts b/packages/common/client/api/components/QueryLoader/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/api/components/QueryLoader/index.ts rename to packages/common/client/api/components/QueryLoader/index.ts diff --git a/examples/simplewebauthn/src/modules/api/components/RefetchButton/RefetchButton.tsx b/packages/common/client/api/components/RefetchButton/RefetchButton.tsx similarity index 89% rename from examples/simplewebauthn/src/modules/api/components/RefetchButton/RefetchButton.tsx rename to packages/common/client/api/components/RefetchButton/RefetchButton.tsx index 38c34c4..28fd0e2 100644 --- a/examples/simplewebauthn/src/modules/api/components/RefetchButton/RefetchButton.tsx +++ b/packages/common/client/api/components/RefetchButton/RefetchButton.tsx @@ -1,5 +1,5 @@ -import { Button } from '@workspace/ui'; -import { RefreshOutlined } from '@workspace/ui/icons'; +import { Button } from '~client/ui-kit'; +import { RefreshOutlined } from '~client/ui-kit/icons'; import type { QueryErrorProps } from '../QueryError'; import { isAnyResultLoading } from '../QueryLoader'; diff --git a/examples/simplewebauthn/src/modules/api/components/RefetchButton/index.ts b/packages/common/client/api/components/RefetchButton/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/api/components/RefetchButton/index.ts rename to packages/common/client/api/components/RefetchButton/index.ts diff --git a/examples/simplewebauthn/src/modules/api/components/index.ts b/packages/common/client/api/components/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/api/components/index.ts rename to packages/common/client/api/components/index.ts diff --git a/examples/simplewebauthn/src/modules/api/fetcher/index.ts b/packages/common/client/api/fetcher/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/api/fetcher/index.ts rename to packages/common/client/api/fetcher/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/CopyToClipboardInput/CopyToClipboardInput.styles.ts b/packages/common/client/clipboard/components/CopyToClipboardInput/CopyToClipboardInput.styles.ts similarity index 87% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/CopyToClipboardInput/CopyToClipboardInput.styles.ts rename to packages/common/client/clipboard/components/CopyToClipboardInput/CopyToClipboardInput.styles.ts index be529c3..d1c4014 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/CopyToClipboardInput/CopyToClipboardInput.styles.ts +++ b/packages/common/client/clipboard/components/CopyToClipboardInput/CopyToClipboardInput.styles.ts @@ -1,4 +1,4 @@ -import { styled } from '@workspace/ui'; +import { styled } from '~client/ui-kit'; export const Textarea = styled('textarea')(({ theme }) => ({ padding: theme.spacing(1), diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/CopyToClipboardInput/CopyToClipboardInput.tsx b/packages/common/client/clipboard/components/CopyToClipboardInput/CopyToClipboardInput.tsx similarity index 87% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/CopyToClipboardInput/CopyToClipboardInput.tsx rename to packages/common/client/clipboard/components/CopyToClipboardInput/CopyToClipboardInput.tsx index 400cf21..a20d243 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/CopyToClipboardInput/CopyToClipboardInput.tsx +++ b/packages/common/client/clipboard/components/CopyToClipboardInput/CopyToClipboardInput.tsx @@ -1,4 +1,4 @@ -import { useCopyTextToClipboard } from '~hooks'; +import { useCopyTextToClipboard } from '~client/clipboard/hooks'; import { Textarea } from './CopyToClipboardInput.styles'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/CopyToClipboardInput/index.ts b/packages/common/client/clipboard/components/CopyToClipboardInput/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/CopyToClipboardInput/index.ts rename to packages/common/client/clipboard/components/CopyToClipboardInput/index.ts diff --git a/packages/common/client/clipboard/components/index.ts b/packages/common/client/clipboard/components/index.ts new file mode 100644 index 0000000..596305e --- /dev/null +++ b/packages/common/client/clipboard/components/index.ts @@ -0,0 +1 @@ +export * from './CopyToClipboardInput'; diff --git a/examples/simplewebauthn/src/hooks/index.ts b/packages/common/client/clipboard/hooks/index.ts similarity index 59% rename from examples/simplewebauthn/src/hooks/index.ts rename to packages/common/client/clipboard/hooks/index.ts index cd010eb..3eac5d3 100644 --- a/examples/simplewebauthn/src/hooks/index.ts +++ b/packages/common/client/clipboard/hooks/index.ts @@ -1,2 +1 @@ export * from './useCopyTextToClipboard'; -export * from './useDialog'; diff --git a/examples/simplewebauthn/src/hooks/useCopyTextToClipboard.ts b/packages/common/client/clipboard/hooks/useCopyTextToClipboard.ts similarity index 92% rename from examples/simplewebauthn/src/hooks/useCopyTextToClipboard.ts rename to packages/common/client/clipboard/hooks/useCopyTextToClipboard.ts index d946eab..de837a9 100644 --- a/examples/simplewebauthn/src/hooks/useCopyTextToClipboard.ts +++ b/packages/common/client/clipboard/hooks/useCopyTextToClipboard.ts @@ -1,7 +1,7 @@ import { useMutation } from '@tanstack/react-query'; +import { useSnack } from '~client/snackbar/hooks'; import { logger } from '~logger'; -import { useSnack } from '~modules/snackbar/hooks'; export function useCopyTextToClipboard() { const snack = useSnack(); diff --git a/examples/simplewebauthn/src/pages/_app.tsx b/packages/common/client/core/components/App.tsx old mode 100755 new mode 100644 similarity index 71% rename from examples/simplewebauthn/src/pages/_app.tsx rename to packages/common/client/core/components/App.tsx index 7f13f75..cac2f63 --- a/examples/simplewebauthn/src/pages/_app.tsx +++ b/packages/common/client/core/components/App.tsx @@ -5,10 +5,9 @@ import type { AppProps } from 'next/app'; import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; import { IntlProvider } from 'react-intl'; -import { EmotionClient, type EmotionClientProps } from '@workspace/ui'; - -import { AppQueryProvider } from '~modules/api/components'; -import { SnackbarProvider } from '~modules/snackbar/components'; +import { AppQueryProvider } from '~client/api/components'; +import { SnackbarProvider } from '~client/snackbar/components'; +import { EmotionClient, type EmotionClientProps } from '~client/ui-kit/styles'; export interface ExtendedAppProps extends AppProps { emotionCache: EmotionClientProps['emotionCache']; @@ -18,7 +17,7 @@ export interface ExtendedAppProps extends AppProps { }; } -function App({ Component, pageProps: { dehydratedState, ...pageProps }, emotionCache }: ExtendedAppProps) { +export function App({ Component, pageProps: { dehydratedState, ...pageProps }, emotionCache }: ExtendedAppProps) { return ( @@ -31,5 +30,3 @@ function App({ Component, pageProps: { dehydratedState, ...pageProps }, emotionC ); } - -export default App; diff --git a/examples/simplewebauthn/src/pages/_document.tsx b/packages/common/client/core/components/Document.tsx similarity index 84% rename from examples/simplewebauthn/src/pages/_document.tsx rename to packages/common/client/core/components/Document.tsx index 3032e59..e72bfad 100644 --- a/examples/simplewebauthn/src/pages/_document.tsx +++ b/packages/common/client/core/components/Document.tsx @@ -1,9 +1,8 @@ import type { AppType } from 'next/app'; +// eslint-disable-next-line @next/next/no-document-import-in-page import Document, { Head, Html, Main, NextScript, type DocumentContext, type DocumentProps } from 'next/document'; -import { createEmotionCacheWithStyleTags } from '@workspace/ui'; - -import { env } from '~env'; +import { createEmotionCacheWithStyleTags } from '~client/ui-kit/styles'; interface MyDocumentProps extends DocumentProps { emotionStyleTags: JSX.Element[]; @@ -21,12 +20,6 @@ function MyDocument({ emotionStyleTags }: MyDocumentProps) { {/* TODO: */} {/* */} - {env.NEXT_PUBLIC_NODE_ENV !== 'production' && ( - - )} {/* TODO: */} {/* */} {/* */} @@ -69,4 +62,4 @@ MyDocument.getInitialProps = async (ctx: DocumentContext) => { }; }; -export default MyDocument; +export { MyDocument }; diff --git a/examples/simplewebauthn/src/pages/_error.jsx b/packages/common/client/core/components/Error.tsx similarity index 58% rename from examples/simplewebauthn/src/pages/_error.jsx rename to packages/common/client/core/components/Error.tsx index 2ddb53e..0c6957f 100644 --- a/examples/simplewebauthn/src/pages/_error.jsx +++ b/packages/common/client/core/components/Error.tsx @@ -1,17 +1,15 @@ import Error from 'next/error'; -import * as Sentry from '@sentry/nextjs'; +import { captureUnderscoreErrorException } from '@sentry/nextjs'; -const CustomErrorComponent = props => { +export const CustomError = (props: any) => { return ; }; -CustomErrorComponent.getInitialProps = async contextData => { +CustomError.getInitialProps = async (contextData: any) => { // In case this is running in a serverless function, await this in order to give Sentry // time to send the error before the lambda exits - await Sentry.captureUnderscoreErrorException(contextData); + await captureUnderscoreErrorException(contextData); // This will contain the status code of the response return Error.getInitialProps(contextData); }; - -export default CustomErrorComponent; diff --git a/packages/common/client/core/components/index.ts b/packages/common/client/core/components/index.ts new file mode 100644 index 0000000..1874654 --- /dev/null +++ b/packages/common/client/core/components/index.ts @@ -0,0 +1,3 @@ +export * from './App'; +export * from './Document'; +export * from './Error'; diff --git a/packages/common/client/dialog/hooks/index.ts b/packages/common/client/dialog/hooks/index.ts new file mode 100644 index 0000000..9d08c25 --- /dev/null +++ b/packages/common/client/dialog/hooks/index.ts @@ -0,0 +1 @@ +export * from './useDialog'; diff --git a/examples/simplewebauthn/src/hooks/useDialog.ts b/packages/common/client/dialog/hooks/useDialog.ts similarity index 100% rename from examples/simplewebauthn/src/hooks/useDialog.ts rename to packages/common/client/dialog/hooks/useDialog.ts diff --git a/examples/simplewebauthn/src/env/env.mjs b/packages/common/client/env/env.mjs similarity index 87% rename from examples/simplewebauthn/src/env/env.mjs rename to packages/common/client/env/env.mjs index a8b72f3..8858de8 100644 --- a/examples/simplewebauthn/src/env/env.mjs +++ b/packages/common/client/env/env.mjs @@ -20,6 +20,8 @@ export const env = createEnv({ NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID: z.string(), NEXT_PUBLIC_FIREBASE_APP_ID: z.string(), NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: z.string(), + + NEXT_PUBLIC_FIRBEASE_DB_ID: z.string().optional(), }, /** @@ -39,11 +41,11 @@ export const env = createEnv({ NEXT_PUBLIC_FIREBASE_APP_ID: process.env.NEXT_PUBLIC_FIREBASE_APP_ID, NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID, + NEXT_PUBLIC_FIRBEASE_DB_ID: process.env.NEXT_PUBLIC_FIRBEASE_DB_ID, + // Dev - ...(process.env.NODE_ENV === 'development' && { - NEXT_PUBLIC_DEV_RETRY_QUERIES: process.env.NEXT_PUBLIC_DEV_RETRY_QUERIES, - NEXT_PUBLIC_DEV_SENTRY_DISABLED: process.env.NEXT_PUBLIC_DEV_SENTRY_DISABLED, - }), + NEXT_PUBLIC_DEV_RETRY_QUERIES: process.env.NEXT_PUBLIC_DEV_RETRY_QUERIES, + NEXT_PUBLIC_DEV_SENTRY_DISABLED: process.env.NEXT_PUBLIC_DEV_SENTRY_DISABLED, }, skipValidation: !!process.env.CI || !!process.env.SKIP_ENV_VALIDATION || process.env.npm_lifecycle_event === 'lint', diff --git a/examples/simplewebauthn/src/env/index.ts b/packages/common/client/env/index.ts similarity index 100% rename from examples/simplewebauthn/src/env/index.ts rename to packages/common/client/env/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthLoader/AuthLoader.tsx b/packages/common/client/example/components/ExampleAuth/AuthLoader/AuthLoader.tsx similarity index 78% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthLoader/AuthLoader.tsx rename to packages/common/client/example/components/ExampleAuth/AuthLoader/AuthLoader.tsx index 4d4e4a4..112cf34 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthLoader/AuthLoader.tsx +++ b/packages/common/client/example/components/ExampleAuth/AuthLoader/AuthLoader.tsx @@ -1,4 +1,4 @@ -import { Loader, LoaderContainer } from '@workspace/ui'; +import { Loader, LoaderContainer } from '~client/ui-kit'; export interface AuthLoaderProps {} diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthLoader/index.ts b/packages/common/client/example/components/ExampleAuth/AuthLoader/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthLoader/index.ts rename to packages/common/client/example/components/ExampleAuth/AuthLoader/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthProvider/AuthProvider.tsx b/packages/common/client/example/components/ExampleAuth/AuthProvider/AuthProvider.tsx similarity index 94% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthProvider/AuthProvider.tsx rename to packages/common/client/example/components/ExampleAuth/AuthProvider/AuthProvider.tsx index 4f0cf33..e6d93bd 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthProvider/AuthProvider.tsx +++ b/packages/common/client/example/components/ExampleAuth/AuthProvider/AuthProvider.tsx @@ -1,8 +1,8 @@ import { useEffect, useRef, useState } from 'react'; import { onAuthStateChanged } from 'firebase/auth'; -import { api } from '~modules/api/fetcher'; -import { auth } from '~modules/firebase/config'; +import { api } from '~client/api/fetcher'; +import { auth } from '~client/firebase/config'; import { AuthContext, type AuthSession } from './contexts'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthProvider/contexts/index.ts b/packages/common/client/example/components/ExampleAuth/AuthProvider/contexts/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthProvider/contexts/index.ts rename to packages/common/client/example/components/ExampleAuth/AuthProvider/contexts/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthProvider/hooks/useAuthUser.ts b/packages/common/client/example/components/ExampleAuth/AuthProvider/hooks/useAuthUser.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthProvider/hooks/useAuthUser.ts rename to packages/common/client/example/components/ExampleAuth/AuthProvider/hooks/useAuthUser.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthProvider/hooks/useExampleAuthSession.ts b/packages/common/client/example/components/ExampleAuth/AuthProvider/hooks/useExampleAuthSession.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthProvider/hooks/useExampleAuthSession.ts rename to packages/common/client/example/components/ExampleAuth/AuthProvider/hooks/useExampleAuthSession.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthProvider/index.ts b/packages/common/client/example/components/ExampleAuth/AuthProvider/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/AuthProvider/index.ts rename to packages/common/client/example/components/ExampleAuth/AuthProvider/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/ExampleAuth.tsx b/packages/common/client/example/components/ExampleAuth/ExampleAuth.tsx similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/ExampleAuth.tsx rename to packages/common/client/example/components/ExampleAuth/ExampleAuth.tsx diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/index.ts b/packages/common/client/example/components/ExampleAuth/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleAuth/index.ts rename to packages/common/client/example/components/ExampleAuth/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleBody/ExampleBody.styles.tsx b/packages/common/client/example/components/ExampleBody/ExampleBody.styles.tsx similarity index 85% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleBody/ExampleBody.styles.tsx rename to packages/common/client/example/components/ExampleBody/ExampleBody.styles.tsx index 28e7358..50e9981 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleBody/ExampleBody.styles.tsx +++ b/packages/common/client/example/components/ExampleBody/ExampleBody.styles.tsx @@ -1,4 +1,4 @@ -import { styled } from '@workspace/ui'; +import { styled } from '~client/ui-kit'; export const ExampleBody = styled('section')(({ theme }) => ({ padding: theme.spacing(3), diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleBody/index.ts b/packages/common/client/example/components/ExampleBody/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleBody/index.ts rename to packages/common/client/example/components/ExampleBody/index.ts diff --git a/packages/ui/src/components/ExampleDescription/ExampleDescription.styles.ts b/packages/common/client/example/components/ExampleDescription/ExampleDescription.styles.ts similarity index 85% rename from packages/ui/src/components/ExampleDescription/ExampleDescription.styles.ts rename to packages/common/client/example/components/ExampleDescription/ExampleDescription.styles.ts index ec9f9ae..098f934 100644 --- a/packages/ui/src/components/ExampleDescription/ExampleDescription.styles.ts +++ b/packages/common/client/example/components/ExampleDescription/ExampleDescription.styles.ts @@ -1,6 +1,6 @@ import { styled } from '@mui/material'; -import { Words } from '../Words'; +import { Words } from '../../../ui-kit/components/Words'; export const Features = styled('ul')(({ theme }) => ({ display: 'grid', diff --git a/packages/ui/src/components/ExampleDescription/ExampleDescription.tsx b/packages/common/client/example/components/ExampleDescription/ExampleDescription.tsx similarity index 93% rename from packages/ui/src/components/ExampleDescription/ExampleDescription.tsx rename to packages/common/client/example/components/ExampleDescription/ExampleDescription.tsx index 1bee06d..698c9a8 100644 --- a/packages/ui/src/components/ExampleDescription/ExampleDescription.tsx +++ b/packages/common/client/example/components/ExampleDescription/ExampleDescription.tsx @@ -1,6 +1,6 @@ import type { ReactNode } from 'react'; -import { Words } from '../Words'; +import { Words } from '../../../ui-kit/components/Words'; import { Feature, Features } from './ExampleDescription.styles'; export interface ExampleDescriptionProps { diff --git a/packages/ui/src/components/ExampleDescription/index.ts b/packages/common/client/example/components/ExampleDescription/index.ts similarity index 100% rename from packages/ui/src/components/ExampleDescription/index.ts rename to packages/common/client/example/components/ExampleDescription/index.ts diff --git a/packages/ui/src/components/ExampleFrame/ExampleFrame.styles.ts b/packages/common/client/example/components/ExampleFrame/ExampleFrame.styles.ts similarity index 100% rename from packages/ui/src/components/ExampleFrame/ExampleFrame.styles.ts rename to packages/common/client/example/components/ExampleFrame/ExampleFrame.styles.ts diff --git a/packages/ui/src/components/ExampleFrame/ExampleFrame.tsx b/packages/common/client/example/components/ExampleFrame/ExampleFrame.tsx similarity index 100% rename from packages/ui/src/components/ExampleFrame/ExampleFrame.tsx rename to packages/common/client/example/components/ExampleFrame/ExampleFrame.tsx diff --git a/packages/ui/src/components/ExampleFrame/index.ts b/packages/common/client/example/components/ExampleFrame/index.ts similarity index 100% rename from packages/ui/src/components/ExampleFrame/index.ts rename to packages/common/client/example/components/ExampleFrame/index.ts diff --git a/packages/ui/src/components/ExampleHeader/ExampleHeader.tsx b/packages/common/client/example/components/ExampleHeader/ExampleHeader.tsx similarity index 91% rename from packages/ui/src/components/ExampleHeader/ExampleHeader.tsx rename to packages/common/client/example/components/ExampleHeader/ExampleHeader.tsx index f52eb3b..254d451 100644 --- a/packages/ui/src/components/ExampleHeader/ExampleHeader.tsx +++ b/packages/common/client/example/components/ExampleHeader/ExampleHeader.tsx @@ -1,7 +1,7 @@ import type { ReactNode } from 'react'; import { Box } from '@mui/material'; -import { Words } from '../Words'; +import { Words } from '../../../ui-kit/components/Words'; export interface ExampleHeaderProps { title: ReactNode; diff --git a/packages/ui/src/components/ExampleHeader/index.ts b/packages/common/client/example/components/ExampleHeader/index.ts similarity index 100% rename from packages/ui/src/components/ExampleHeader/index.ts rename to packages/common/client/example/components/ExampleHeader/index.ts diff --git a/packages/common/client/example/components/ExampleRouter/createExampleRouter.tsx b/packages/common/client/example/components/ExampleRouter/createExampleRouter.tsx new file mode 100644 index 0000000..e575b69 --- /dev/null +++ b/packages/common/client/example/components/ExampleRouter/createExampleRouter.tsx @@ -0,0 +1,55 @@ +import { createContext, createElement, useContext, useState, type ReactElement, type ReactNode } from 'react'; + +export type Pathname = string; +export type RenderRoute = () => ReactElement; +export type UnknownRoutes = Readonly>; + +export function createExampleRouter() { + type Route = keyof Routes; + + type ExampleRouterContextValue = { + routes: Routes; + currentRoute: Route; + redirect: (route: Route) => void; + }; + + const ExampleRouterContext = createContext(undefined); + + interface ExampleRouterProps { + children: ReactNode; + initialRoute: Route; + routes: Routes; + } + + const ExampleRouter = ({ children, initialRoute, routes }: ExampleRouterProps) => { + const [currentRoute, setCurrentRoute] = useState(initialRoute); + + return ( + + {children} + + ); + }; + + function useExampleRouter() { + const context = useContext(ExampleRouterContext); + + if (!context) { + throw new Error('useExampleRouter must be used within an ExampleRouterContext.Provider'); + } + + return context; + } + + function CurrentExampleRoute() { + const { routes, currentRoute } = useExampleRouter(); + + return createElement(routes[currentRoute]); + } + + return { + ExampleRouter, + useExampleRouter, + CurrentExampleRoute, + } as const; +} diff --git a/packages/common/client/example/components/ExampleRouter/index.ts b/packages/common/client/example/components/ExampleRouter/index.ts new file mode 100644 index 0000000..5ebe849 --- /dev/null +++ b/packages/common/client/example/components/ExampleRouter/index.ts @@ -0,0 +1 @@ +export * from './createExampleRouter'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.styles.ts b/packages/common/client/example/components/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.styles.ts similarity index 80% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.styles.ts rename to packages/common/client/example/components/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.styles.ts index ad0c830..70ee4f5 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.styles.ts +++ b/packages/common/client/example/components/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.styles.ts @@ -1,4 +1,4 @@ -import { styled } from '@workspace/ui'; +import { styled } from '~client/ui-kit'; export const Row = styled('div')(({ theme }) => ({ display: 'grid', diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.tsx b/packages/common/client/example/components/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.tsx similarity index 75% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.tsx rename to packages/common/client/example/components/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.tsx index e1efff7..a035426 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.tsx +++ b/packages/common/client/example/components/ExampleTopBar/AuthUserDropdown/AuthUserDropdown.tsx @@ -1,12 +1,16 @@ import { useState } from 'react'; -import { Box, Divider, IconButton, Menu, MenuItem } from '@workspace/ui'; -import { AccountCircle } from '@workspace/ui/icons'; +import { useExampleAuthSession } from '~client/example/components'; +import { Box, Divider, IconButton, Menu, MenuItem } from '~client/ui-kit'; +import { AccountCircle } from '~client/ui-kit/icons'; -import { useExampleAuthSession } from '../../ExampleAuth'; import { useLogout } from './hooks/useLogout'; -export const AuthUserDropdown = () => { +export interface AuthUserDropdownProps { + onLogout: () => void; +} + +export const AuthUserDropdown = ({ onLogout }: AuthUserDropdownProps) => { const { session } = useExampleAuthSession(); const [anchorEl, setAnchorEl] = useState(null); const [open, setOpen] = useState(false); @@ -20,7 +24,10 @@ export const AuthUserDropdown = () => { setOpen(false); }; - const logout = useLogout(handleClose); + const logout = useLogout(() => { + onLogout?.(); + handleClose(); + }); if (session.state !== 'authenticated') { return null; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/AuthUserDropdown/hooks/useLogout.ts b/packages/common/client/example/components/ExampleTopBar/AuthUserDropdown/hooks/useLogout.ts similarity index 59% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/AuthUserDropdown/hooks/useLogout.ts rename to packages/common/client/example/components/ExampleTopBar/AuthUserDropdown/hooks/useLogout.ts index db86e66..79ec5af 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/AuthUserDropdown/hooks/useLogout.ts +++ b/packages/common/client/example/components/ExampleTopBar/AuthUserDropdown/hooks/useLogout.ts @@ -1,18 +1,12 @@ import { useMutation } from '@tanstack/react-query'; -import { auth } from '~modules/firebase/config'; - -import { useExampleRouter } from '../../../ExampleRouter'; +import { auth } from '~client/firebase/config'; export function useLogout(onSuccess?: () => void) { - const { redirect } = useExampleRouter(); - return useMutation({ mutationKey: ['logout'], mutationFn: async () => { await auth().signOut(); - - redirect('/login'); }, onSuccess, }); diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/AuthUserDropdown/index.ts b/packages/common/client/example/components/ExampleTopBar/AuthUserDropdown/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/AuthUserDropdown/index.ts rename to packages/common/client/example/components/ExampleTopBar/AuthUserDropdown/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/ExampleTopBar.styles.ts b/packages/common/client/example/components/ExampleTopBar/ExampleTopBar.styles.ts similarity index 88% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/ExampleTopBar.styles.ts rename to packages/common/client/example/components/ExampleTopBar/ExampleTopBar.styles.ts index 649bbd5..e3d5050 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/ExampleTopBar.styles.ts +++ b/packages/common/client/example/components/ExampleTopBar/ExampleTopBar.styles.ts @@ -1,4 +1,4 @@ -import { styled } from '@workspace/ui'; +import { styled } from '~client/ui-kit'; export const Topbar = styled('section')(({ theme }) => ({ display: 'grid', diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/ExampleTopBar.tsx b/packages/common/client/example/components/ExampleTopBar/ExampleTopBar.tsx similarity index 70% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/ExampleTopBar.tsx rename to packages/common/client/example/components/ExampleTopBar/ExampleTopBar.tsx index 3077480..48b3df1 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/ExampleTopBar.tsx +++ b/packages/common/client/example/components/ExampleTopBar/ExampleTopBar.tsx @@ -1,19 +1,21 @@ -import { IconButton, Words } from '@workspace/ui'; -import { Fullscreen, FullscreenExit } from '@workspace/ui/icons'; +import type { ReactNode } from 'react'; +import { Fullscreen, FullscreenExit } from '@mui/icons-material'; + +import { IconButton, Words } from '~client/ui-kit'; import { useExampleAuthSession } from '../ExampleAuth'; import { AuthUserDropdown } from './AuthUserDropdown'; import { Topbar } from './ExampleTopBar.styles'; -import { useExampleRouteTitle } from './hooks/useExampleRouteTitle'; export interface ExampleTopBarProps { onToggleExpand: (expanded: boolean) => void; expanded: boolean; + title: ReactNode; + onLogout: () => void; } -export const ExampleTopBar = ({ onToggleExpand, expanded }: ExampleTopBarProps) => { +export const ExampleTopBar = ({ onToggleExpand, expanded, title, onLogout }: ExampleTopBarProps) => { const { session } = useExampleAuthSession(); - const routeTitle = useExampleRouteTitle(); return ( @@ -30,10 +32,10 @@ export const ExampleTopBar = ({ onToggleExpand, expanded }: ExampleTopBarProps) fontWeight: 'bold', }} > - {routeTitle} + {title} - {session.state === 'authenticated' ? : } + {session.state === 'authenticated' ? : } ); }; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/index.ts b/packages/common/client/example/components/ExampleTopBar/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/ExampleTopBar/index.ts rename to packages/common/client/example/components/ExampleTopBar/index.ts diff --git a/packages/common/client/example/components/ExampleWrapper/ExampleWrapper.styles.ts b/packages/common/client/example/components/ExampleWrapper/ExampleWrapper.styles.ts new file mode 100644 index 0000000..a03e892 --- /dev/null +++ b/packages/common/client/example/components/ExampleWrapper/ExampleWrapper.styles.ts @@ -0,0 +1,7 @@ +import { styled } from '~client/ui-kit'; + +export const ExampleWrapper = styled('div')(({ theme }) => ({ + paddingTop: theme.spacing(7), + paddingBottom: theme.spacing(7), + backgroundColor: theme.palette.grey[100], +})); diff --git a/packages/common/client/example/components/ExampleWrapper/index.ts b/packages/common/client/example/components/ExampleWrapper/index.ts new file mode 100644 index 0000000..c2e6157 --- /dev/null +++ b/packages/common/client/example/components/ExampleWrapper/index.ts @@ -0,0 +1 @@ +export * from './ExampleWrapper.styles'; diff --git a/packages/common/client/example/components/index.ts b/packages/common/client/example/components/index.ts new file mode 100644 index 0000000..abaa584 --- /dev/null +++ b/packages/common/client/example/components/index.ts @@ -0,0 +1,8 @@ +export * from './ExampleAuth'; +export * from './ExampleBody'; +export * from './ExampleDescription'; +export * from './ExampleFrame'; +export * from './ExampleHeader'; +export * from './ExampleRouter'; +export * from './ExampleTopBar'; +export * from './ExampleWrapper'; diff --git a/examples/simplewebauthn/src/modules/firebase/config/index.ts b/packages/common/client/firebase/config/index.ts similarity index 81% rename from examples/simplewebauthn/src/modules/firebase/config/index.ts rename to packages/common/client/firebase/config/index.ts index f5b5ec9..7dfb6e2 100644 --- a/examples/simplewebauthn/src/modules/firebase/config/index.ts +++ b/packages/common/client/firebase/config/index.ts @@ -3,7 +3,7 @@ import { initializeApp } from 'firebase/app'; import { getAuth } from 'firebase/auth'; import { getFirestore } from 'firebase/firestore'; -import { env } from '~env'; +import { env } from '~client/env'; let app: ReturnType; @@ -30,4 +30,9 @@ export const getFirebaseApp = () => { export const auth = () => getAuth(getFirebaseApp()); export const analytics = () => getAnalytics(getFirebaseApp()); -export const db = () => getFirestore(getFirebaseApp()); +export const db = () => { + const app = getFirebaseApp(); + const databaseId = env.NEXT_PUBLIC_FIRBEASE_DB_ID; + + return databaseId ? getFirestore(app, databaseId) : getFirestore(app); +}; diff --git a/examples/simplewebauthn/src/modules/firebase/services/passkeys.ts b/packages/common/client/firebase/services/passkeys.ts similarity index 77% rename from examples/simplewebauthn/src/modules/firebase/services/passkeys.ts rename to packages/common/client/firebase/services/passkeys.ts index f1e4fb2..c61e764 100644 --- a/examples/simplewebauthn/src/modules/firebase/services/passkeys.ts +++ b/packages/common/client/firebase/services/passkeys.ts @@ -1,9 +1,8 @@ import { collection, getDocs, limit, orderBy, query, where } from 'firebase/firestore'; -import { collections } from '~server/constants/collections'; -import type { Passkey } from '~server/types'; - -import { db } from '../config'; +import { db } from '@workspace/common/client/firebase/config'; +import { collections } from '@workspace/common/server/constants/collections'; +import type { Passkey } from '@workspace/common/types'; export const getPasskeys = async (userId: Passkey['userId']) => { const passkeysCollection = collection(db(), collections.Passkeys); diff --git a/examples/simplewebauthn/src/modules/form/components/EmailField/EmailField.tsx b/packages/common/client/form/components/EmailField/EmailField.tsx similarity index 88% rename from examples/simplewebauthn/src/modules/form/components/EmailField/EmailField.tsx rename to packages/common/client/form/components/EmailField/EmailField.tsx index ed68dc9..28eafe6 100644 --- a/examples/simplewebauthn/src/modules/form/components/EmailField/EmailField.tsx +++ b/packages/common/client/form/components/EmailField/EmailField.tsx @@ -2,7 +2,9 @@ import { useEffect } from 'react'; import { useSearchParams } from 'next/navigation'; import { useFormContext, type Path } from 'react-hook-form'; -import { TextField, type TextFieldProps, type UnknownFormValues } from '@workspace/ui'; +import type { UnknownFormValues } from '~client/form/types'; + +import { TextField, type TextFieldProps } from '../fields'; export interface EmailFieldProps extends TextFieldProps { name: Path; diff --git a/examples/simplewebauthn/src/modules/form/components/EmailField/index.ts b/packages/common/client/form/components/EmailField/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/form/components/EmailField/index.ts rename to packages/common/client/form/components/EmailField/index.ts diff --git a/packages/ui/src/modules/form/components/FieldsStack/FieldsStack.styles.ts b/packages/common/client/form/components/FieldsStack/FieldsStack.styles.ts similarity index 78% rename from packages/ui/src/modules/form/components/FieldsStack/FieldsStack.styles.ts rename to packages/common/client/form/components/FieldsStack/FieldsStack.styles.ts index 425e638..366e48a 100644 --- a/packages/ui/src/modules/form/components/FieldsStack/FieldsStack.styles.ts +++ b/packages/common/client/form/components/FieldsStack/FieldsStack.styles.ts @@ -1,4 +1,4 @@ -import { styled } from '@mui/material'; +import { styled } from '~client/ui-kit'; export const FieldsStack = styled('div')(({ theme }) => ({ display: 'grid', diff --git a/packages/ui/src/modules/form/components/FieldsStack/index.ts b/packages/common/client/form/components/FieldsStack/index.ts similarity index 100% rename from packages/ui/src/modules/form/components/FieldsStack/index.ts rename to packages/common/client/form/components/FieldsStack/index.ts diff --git a/examples/simplewebauthn/src/modules/form/components/Form/Form.tsx b/packages/common/client/form/components/Form/Form.tsx similarity index 88% rename from examples/simplewebauthn/src/modules/form/components/Form/Form.tsx rename to packages/common/client/form/components/Form/Form.tsx index ad7b51d..4478052 100644 --- a/examples/simplewebauthn/src/modules/form/components/Form/Form.tsx +++ b/packages/common/client/form/components/Form/Form.tsx @@ -1,9 +1,8 @@ import { useMemo } from 'react'; import { FormProvider, useForm, type UseFormProps, type UseFormReturn } from 'react-hook-form'; -import type { UnknownFormValues } from '@workspace/ui'; - -import { useLocalizedResolver, type UnkownFormSchema } from '~modules/form/hooks'; +import { useLocalizedResolver } from '~client/form/hooks'; +import type { UnknownFormValues, UnkownFormSchema } from '~client/form/types'; export interface FormProps { schema: FormSchema; diff --git a/examples/simplewebauthn/src/modules/form/components/Form/index.ts b/packages/common/client/form/components/Form/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/form/components/Form/index.ts rename to packages/common/client/form/components/Form/index.ts diff --git a/packages/ui/src/modules/form/components/FormError/FormError.tsx b/packages/common/client/form/components/FormError/FormError.tsx similarity index 100% rename from packages/ui/src/modules/form/components/FormError/FormError.tsx rename to packages/common/client/form/components/FormError/FormError.tsx diff --git a/packages/ui/src/modules/form/components/FormError/index.ts b/packages/common/client/form/components/FormError/index.ts similarity index 100% rename from packages/ui/src/modules/form/components/FormError/index.ts rename to packages/common/client/form/components/FormError/index.ts diff --git a/examples/simplewebauthn/src/modules/form/components/PasswordField/PasswordField.tsx b/packages/common/client/form/components/PasswordField/PasswordField.tsx similarity index 88% rename from examples/simplewebauthn/src/modules/form/components/PasswordField/PasswordField.tsx rename to packages/common/client/form/components/PasswordField/PasswordField.tsx index 957a55f..e6c69f3 100644 --- a/examples/simplewebauthn/src/modules/form/components/PasswordField/PasswordField.tsx +++ b/packages/common/client/form/components/PasswordField/PasswordField.tsx @@ -2,8 +2,9 @@ import { useState } from 'react'; import { InputAdornment } from '@mui/material'; import type { Path } from 'react-hook-form'; -import { TextField, type TextFieldProps, type UnknownFormValues } from '@workspace/ui'; +import type { UnknownFormValues } from '~client/form/types'; +import { TextField, type TextFieldProps } from '../fields/TextField'; import { TogglePasswordVisibility, type PasswordType } from './TogglePasswordVisibility'; export interface PasswordFieldProps extends TextFieldProps { diff --git a/examples/simplewebauthn/src/modules/form/components/PasswordField/TogglePasswordVisibility/TogglePasswordVisibility.tsx b/packages/common/client/form/components/PasswordField/TogglePasswordVisibility/TogglePasswordVisibility.tsx similarity index 80% rename from examples/simplewebauthn/src/modules/form/components/PasswordField/TogglePasswordVisibility/TogglePasswordVisibility.tsx rename to packages/common/client/form/components/PasswordField/TogglePasswordVisibility/TogglePasswordVisibility.tsx index c72fbe8..4f69fe9 100644 --- a/examples/simplewebauthn/src/modules/form/components/PasswordField/TogglePasswordVisibility/TogglePasswordVisibility.tsx +++ b/packages/common/client/form/components/PasswordField/TogglePasswordVisibility/TogglePasswordVisibility.tsx @@ -1,7 +1,5 @@ -import { IconButton } from '@mui/material'; - -import { Icon } from '@workspace/ui'; -import { Visibility, VisibilityOff } from '@workspace/ui/icons'; +import { Icon, IconButton } from '~client/ui-kit'; +import { Visibility, VisibilityOff } from '~client/ui-kit/icons'; export type PasswordType = 'text' | 'password'; diff --git a/examples/simplewebauthn/src/modules/form/components/PasswordField/TogglePasswordVisibility/index.ts b/packages/common/client/form/components/PasswordField/TogglePasswordVisibility/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/form/components/PasswordField/TogglePasswordVisibility/index.ts rename to packages/common/client/form/components/PasswordField/TogglePasswordVisibility/index.ts diff --git a/examples/simplewebauthn/src/modules/form/components/PasswordField/index.ts b/packages/common/client/form/components/PasswordField/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/form/components/PasswordField/index.ts rename to packages/common/client/form/components/PasswordField/index.ts diff --git a/examples/simplewebauthn/src/modules/form/components/SubmitButton/SubmitButton.tsx b/packages/common/client/form/components/SubmitButton/SubmitButton.tsx similarity index 88% rename from examples/simplewebauthn/src/modules/form/components/SubmitButton/SubmitButton.tsx rename to packages/common/client/form/components/SubmitButton/SubmitButton.tsx index 48ce91a..bf39b99 100644 --- a/examples/simplewebauthn/src/modules/form/components/SubmitButton/SubmitButton.tsx +++ b/packages/common/client/form/components/SubmitButton/SubmitButton.tsx @@ -1,6 +1,6 @@ import { useFormContext } from 'react-hook-form'; -import { Button, type ButtonProps } from '@workspace/ui'; +import { Button, type ButtonProps } from '~client/ui-kit'; export interface SubmitButtonProps extends Omit { children?: React.ReactNode; diff --git a/examples/simplewebauthn/src/modules/form/components/SubmitButton/index.ts b/packages/common/client/form/components/SubmitButton/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/form/components/SubmitButton/index.ts rename to packages/common/client/form/components/SubmitButton/index.ts diff --git a/packages/ui/src/modules/form/components/fields/SelectField/SelectField.tsx b/packages/common/client/form/components/fields/SelectField/SelectField.tsx similarity index 96% rename from packages/ui/src/modules/form/components/fields/SelectField/SelectField.tsx rename to packages/common/client/form/components/fields/SelectField/SelectField.tsx index 62b7f78..48ef3c2 100644 --- a/packages/ui/src/modules/form/components/fields/SelectField/SelectField.tsx +++ b/packages/common/client/form/components/fields/SelectField/SelectField.tsx @@ -1,7 +1,8 @@ import { forwardRef, type ForwardedRef } from 'react'; import { useController, useFormContext, type Path } from 'react-hook-form'; -import type { UnknownFormValues } from '../../../types'; +import type { UnknownFormValues } from '~client/form/types'; + import { Select, type DefaultSelectOption, type SelectProps } from '../../inputs'; interface SelectFieldProps diff --git a/packages/ui/src/modules/form/components/fields/SelectField/index.ts b/packages/common/client/form/components/fields/SelectField/index.ts similarity index 100% rename from packages/ui/src/modules/form/components/fields/SelectField/index.ts rename to packages/common/client/form/components/fields/SelectField/index.ts diff --git a/packages/ui/src/modules/form/components/fields/TextField/TextField.styles.ts b/packages/common/client/form/components/fields/TextField/TextField.styles.ts similarity index 89% rename from packages/ui/src/modules/form/components/fields/TextField/TextField.styles.ts rename to packages/common/client/form/components/fields/TextField/TextField.styles.ts index 5a0ced6..62ae134 100644 --- a/packages/ui/src/modules/form/components/fields/TextField/TextField.styles.ts +++ b/packages/common/client/form/components/fields/TextField/TextField.styles.ts @@ -1,4 +1,4 @@ -import { styled } from '@mui/material'; +import { styled } from '~client/ui-kit'; export const StyledContainer = styled('div', { shouldForwardProp: prop => prop !== 'fullWidth', diff --git a/packages/ui/src/modules/form/components/fields/TextField/TextField.tsx b/packages/common/client/form/components/fields/TextField/TextField.tsx similarity index 96% rename from packages/ui/src/modules/form/components/fields/TextField/TextField.tsx rename to packages/common/client/form/components/fields/TextField/TextField.tsx index c790a49..80c9f26 100644 --- a/packages/ui/src/modules/form/components/fields/TextField/TextField.tsx +++ b/packages/common/client/form/components/fields/TextField/TextField.tsx @@ -1,6 +1,7 @@ import { useController, useFormContext, type Path } from 'react-hook-form'; -import type { UnknownFormValues } from '../../../types'; +import type { UnknownFormValues } from '~client/form/types'; + import { TextInput, type TextInputProps } from '../../inputs'; import { InputContainer, StyledContainer } from './TextField.styles'; diff --git a/packages/ui/src/modules/form/components/fields/TextField/index.ts b/packages/common/client/form/components/fields/TextField/index.ts similarity index 100% rename from packages/ui/src/modules/form/components/fields/TextField/index.ts rename to packages/common/client/form/components/fields/TextField/index.ts diff --git a/packages/ui/src/modules/form/components/fields/index.ts b/packages/common/client/form/components/fields/index.ts similarity index 100% rename from packages/ui/src/modules/form/components/fields/index.ts rename to packages/common/client/form/components/fields/index.ts diff --git a/examples/simplewebauthn/src/modules/form/components/index.ts b/packages/common/client/form/components/index.ts similarity index 66% rename from examples/simplewebauthn/src/modules/form/components/index.ts rename to packages/common/client/form/components/index.ts index 7cedb31..4d2bbc5 100644 --- a/examples/simplewebauthn/src/modules/form/components/index.ts +++ b/packages/common/client/form/components/index.ts @@ -1,4 +1,6 @@ export * from './EmailField'; +export * from './FieldsStack'; export * from './Form'; +export * from './FormError'; export * from './PasswordField'; export * from './SubmitButton'; diff --git a/packages/ui/src/modules/form/components/inputs/Select/Select.styles.ts b/packages/common/client/form/components/inputs/Select/Select.styles.ts similarity index 100% rename from packages/ui/src/modules/form/components/inputs/Select/Select.styles.ts rename to packages/common/client/form/components/inputs/Select/Select.styles.ts diff --git a/packages/ui/src/modules/form/components/inputs/Select/Select.tsx b/packages/common/client/form/components/inputs/Select/Select.tsx similarity index 100% rename from packages/ui/src/modules/form/components/inputs/Select/Select.tsx rename to packages/common/client/form/components/inputs/Select/Select.tsx diff --git a/packages/ui/src/modules/form/components/inputs/Select/index.ts b/packages/common/client/form/components/inputs/Select/index.ts similarity index 100% rename from packages/ui/src/modules/form/components/inputs/Select/index.ts rename to packages/common/client/form/components/inputs/Select/index.ts diff --git a/packages/ui/src/modules/form/components/inputs/TextInput/TextInput.styles.ts b/packages/common/client/form/components/inputs/TextInput/TextInput.styles.ts similarity index 100% rename from packages/ui/src/modules/form/components/inputs/TextInput/TextInput.styles.ts rename to packages/common/client/form/components/inputs/TextInput/TextInput.styles.ts diff --git a/packages/ui/src/modules/form/components/inputs/TextInput/TextInput.tsx b/packages/common/client/form/components/inputs/TextInput/TextInput.tsx similarity index 100% rename from packages/ui/src/modules/form/components/inputs/TextInput/TextInput.tsx rename to packages/common/client/form/components/inputs/TextInput/TextInput.tsx diff --git a/packages/ui/src/modules/form/components/inputs/TextInput/index.ts b/packages/common/client/form/components/inputs/TextInput/index.ts similarity index 100% rename from packages/ui/src/modules/form/components/inputs/TextInput/index.ts rename to packages/common/client/form/components/inputs/TextInput/index.ts diff --git a/packages/ui/src/modules/form/components/inputs/index.ts b/packages/common/client/form/components/inputs/index.ts similarity index 100% rename from packages/ui/src/modules/form/components/inputs/index.ts rename to packages/common/client/form/components/inputs/index.ts diff --git a/examples/simplewebauthn/src/modules/form/errors/index.ts b/packages/common/client/form/errors/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/form/errors/index.ts rename to packages/common/client/form/errors/index.ts diff --git a/examples/simplewebauthn/src/modules/form/hooks/index.ts b/packages/common/client/form/hooks/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/form/hooks/index.ts rename to packages/common/client/form/hooks/index.ts diff --git a/examples/simplewebauthn/src/modules/form/hooks/useLocalizedResolver.ts b/packages/common/client/form/hooks/useLocalizedResolver.ts similarity index 92% rename from examples/simplewebauthn/src/modules/form/hooks/useLocalizedResolver.ts rename to packages/common/client/form/hooks/useLocalizedResolver.ts index 1bac9f0..95a38ca 100644 --- a/examples/simplewebauthn/src/modules/form/hooks/useLocalizedResolver.ts +++ b/packages/common/client/form/hooks/useLocalizedResolver.ts @@ -1,7 +1,8 @@ import { useCallback, useMemo } from 'react'; import { zodResolver } from '@hookform/resolvers/zod'; import type { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form'; -import type { z } from 'zod'; + +import type { UnkownFormSchema } from '~client/form/types'; export type LocalizedZodResolver = ( values: TFieldValues, @@ -9,8 +10,6 @@ export type LocalizedZodResolver = ( options: ResolverOptions, ) => Promise>; -export type UnkownFormSchema = z.Schema; - /** * Extend the zodResolver with the ability to translate the error messages. */ diff --git a/packages/common/client/form/types/index.ts b/packages/common/client/form/types/index.ts new file mode 100644 index 0000000..2060bd5 --- /dev/null +++ b/packages/common/client/form/types/index.ts @@ -0,0 +1,5 @@ +import type { z } from 'zod'; + +export type UnknownFormValues = Record; + +export type UnkownFormSchema = z.Schema; diff --git a/examples/simplewebauthn/src/modules/form/validators/general.ts b/packages/common/client/form/validators/general.ts similarity index 100% rename from examples/simplewebauthn/src/modules/form/validators/general.ts rename to packages/common/client/form/validators/general.ts diff --git a/examples/simplewebauthn/src/modules/form/validators/index.ts b/packages/common/client/form/validators/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/form/validators/index.ts rename to packages/common/client/form/validators/index.ts diff --git a/examples/simplewebauthn/src/modules/form/validators/password.ts b/packages/common/client/form/validators/password.ts similarity index 100% rename from examples/simplewebauthn/src/modules/form/validators/password.ts rename to packages/common/client/form/validators/password.ts diff --git a/examples/simplewebauthn/src/modules/layout/components/MainHeader/MainHeader.tsx b/packages/common/client/layout/components/MainHeader/MainHeader.tsx similarity index 88% rename from examples/simplewebauthn/src/modules/layout/components/MainHeader/MainHeader.tsx rename to packages/common/client/layout/components/MainHeader/MainHeader.tsx index 8af557d..a4b9097 100644 --- a/examples/simplewebauthn/src/modules/layout/components/MainHeader/MainHeader.tsx +++ b/packages/common/client/layout/components/MainHeader/MainHeader.tsx @@ -1,6 +1,6 @@ import Head from 'next/head'; -import { PageHeader } from '@workspace/ui'; +import { PageHeader } from '~client/ui-kit'; export interface MainHeaderProps { pageTitle: string; diff --git a/examples/simplewebauthn/src/modules/layout/components/MainHeader/index.ts b/packages/common/client/layout/components/MainHeader/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/layout/components/MainHeader/index.ts rename to packages/common/client/layout/components/MainHeader/index.ts diff --git a/examples/simplewebauthn/src/modules/layout/components/index.ts b/packages/common/client/layout/components/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/layout/components/index.ts rename to packages/common/client/layout/components/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/BackedUp/BackedUp.tsx b/packages/common/client/passkeys/components/Passkey/BackedUp/BackedUp.tsx similarity index 89% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/BackedUp/BackedUp.tsx rename to packages/common/client/passkeys/components/Passkey/BackedUp/BackedUp.tsx index 98e1dac..8d1c34a 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/BackedUp/BackedUp.tsx +++ b/packages/common/client/passkeys/components/Passkey/BackedUp/BackedUp.tsx @@ -1,5 +1,5 @@ -import { Code, Icon, Strong, TextBlock } from '@workspace/ui'; -import { Check, Clear } from '@workspace/ui/icons'; +import { Code, Icon, Strong, TextBlock } from '~client/ui-kit'; +import { Check, Clear } from '~client/ui-kit/icons'; import { Caption } from '../Caption'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/BackedUp/index.ts b/packages/common/client/passkeys/components/Passkey/BackedUp/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/BackedUp/index.ts rename to packages/common/client/passkeys/components/Passkey/BackedUp/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Caption/Caption.styles.ts b/packages/common/client/passkeys/components/Passkey/Caption/Caption.styles.ts similarity index 80% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Caption/Caption.styles.ts rename to packages/common/client/passkeys/components/Passkey/Caption/Caption.styles.ts index 06ebffc..3fb25d4 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Caption/Caption.styles.ts +++ b/packages/common/client/passkeys/components/Passkey/Caption/Caption.styles.ts @@ -1,4 +1,4 @@ -import { styled } from '@workspace/ui'; +import { styled } from '~client/ui-kit'; export const CaptionWrapper = styled('div')(({ theme }) => ({ display: 'flex', diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Caption/Caption.tsx b/packages/common/client/passkeys/components/Passkey/Caption/Caption.tsx similarity index 90% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Caption/Caption.tsx rename to packages/common/client/passkeys/components/Passkey/Caption/Caption.tsx index 926d9ab..ce7ac51 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Caption/Caption.tsx +++ b/packages/common/client/passkeys/components/Passkey/Caption/Caption.tsx @@ -1,6 +1,6 @@ import type { ReactNode } from 'react'; -import { InfoTooltip, Words } from '@workspace/ui'; +import { InfoTooltip, Words } from '~client/ui-kit'; import { CaptionWrapper } from './Caption.styles'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Caption/index.ts b/packages/common/client/passkeys/components/Passkey/Caption/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Caption/index.ts rename to packages/common/client/passkeys/components/Passkey/Caption/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Counter/Counter.tsx b/packages/common/client/passkeys/components/Passkey/Counter/Counter.tsx similarity index 91% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Counter/Counter.tsx rename to packages/common/client/passkeys/components/Passkey/Counter/Counter.tsx index b56203d..db0b8f0 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Counter/Counter.tsx +++ b/packages/common/client/passkeys/components/Passkey/Counter/Counter.tsx @@ -1,4 +1,4 @@ -import { Box, InfoTooltip, Words } from '@workspace/ui'; +import { Box, InfoTooltip, Words } from '~client/ui-kit'; export interface CounterProps { value: number; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Counter/index.ts b/packages/common/client/passkeys/components/Passkey/Counter/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Counter/index.ts rename to packages/common/client/passkeys/components/Passkey/Counter/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/DeviceType/DeviceType.tsx b/packages/common/client/passkeys/components/Passkey/DeviceType/DeviceType.tsx similarity index 88% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/DeviceType/DeviceType.tsx rename to packages/common/client/passkeys/components/Passkey/DeviceType/DeviceType.tsx index 5cea5d9..5128cc5 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/DeviceType/DeviceType.tsx +++ b/packages/common/client/passkeys/components/Passkey/DeviceType/DeviceType.tsx @@ -1,12 +1,12 @@ -import { ExternalLink, Icon, Strong, TextBlock } from '@workspace/ui'; -import { Check, Clear } from '@workspace/ui/icons'; +import type { CredentialDeviceType } from '@simplewebauthn/types'; -import type { Passkey } from '~server/types'; +import { ExternalLink, Icon, Strong, TextBlock } from '~client/ui-kit'; +import { Check, Clear } from '~client/ui-kit/icons'; import { Caption } from '../Caption'; export interface DeviceTypeProps { - value: Passkey['credentialDeviceType']; + value: CredentialDeviceType; } export const DeviceType = ({ value }: DeviceTypeProps) => { diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/DeviceType/index.ts b/packages/common/client/passkeys/components/Passkey/DeviceType/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/DeviceType/index.ts rename to packages/common/client/passkeys/components/Passkey/DeviceType/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkeys.styles.ts b/packages/common/client/passkeys/components/Passkey/Passkey.styles.ts similarity index 58% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkeys.styles.ts rename to packages/common/client/passkeys/components/Passkey/Passkey.styles.ts index 954eb4b..d346ef1 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkeys.styles.ts +++ b/packages/common/client/passkeys/components/Passkey/Passkey.styles.ts @@ -1,4 +1,4 @@ -import { Divider, styled } from '@workspace/ui'; +import { Divider, styled } from '~client/ui-kit'; export const StyledDivider = styled(Divider)(({ theme }) => ({ marginTop: theme.spacing(3.5), @@ -21,17 +21,3 @@ export const DetailsRows = styled('div')(({ theme }) => ({ alignItems: 'center', justifyContent: 'flex-start', })); - -export const PasskeysHeader = styled('header')(({ theme }) => ({ - marginBottom: theme.spacing(2), - marginTop: theme.spacing(2), - display: 'grid', - justifyContent: 'space-between', - alignItems: 'center', - gridTemplateColumns: 'auto auto', -})); - -export const PasskeysList = styled('section')(({ theme }) => ({ - display: 'grid', - rowGap: theme.spacing(3.5), -})); diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Passkey.tsx b/packages/common/client/passkeys/components/Passkey/Passkey.tsx similarity index 88% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Passkey.tsx rename to packages/common/client/passkeys/components/Passkey/Passkey.tsx index 6e03c99..d420415 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Passkey.tsx +++ b/packages/common/client/passkeys/components/Passkey/Passkey.tsx @@ -1,14 +1,14 @@ -import { Button, Card, CardContent } from '@workspace/ui'; -import { Delete } from '@workspace/ui/icons'; +import type { UseMutationResult } from '@tanstack/react-query'; -import type { Passkey as TPasskey } from '~server/types'; +import type { Passkey as TPasskey } from '~client/types'; +import { Button, Card, CardContent } from '~client/ui-kit'; +import { Delete } from '~client/ui-kit/icons'; -import type { useRemovePasskey } from '../hooks/useRemovePasskey'; -import { DetailsGrid, DetailsRows, StyledDivider } from '../Passkeys.styles'; import { BackedUp } from './BackedUp'; import { Caption } from './Caption'; import { Counter } from './Counter'; import { DeviceType } from './DeviceType'; +import { DetailsGrid, DetailsRows, StyledDivider } from './Passkey.styles'; import { PasskeyID } from './PasskeyID'; import { Provider } from './Provider'; import { PublicKey } from './PublicKey'; @@ -19,7 +19,7 @@ import { Transports } from './Transports'; export interface PasskeyProps { passkey: TPasskey; removable: boolean; - removePasskey: ReturnType; + removePasskey: UseMutationResult; } export const Passkey = ({ passkey, removable, removePasskey }: PasskeyProps) => { diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PasskeyID/PasskeyID.tsx b/packages/common/client/passkeys/components/Passkey/PasskeyID/PasskeyID.tsx similarity index 84% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PasskeyID/PasskeyID.tsx rename to packages/common/client/passkeys/components/Passkey/PasskeyID/PasskeyID.tsx index 70466eb..0d88680 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PasskeyID/PasskeyID.tsx +++ b/packages/common/client/passkeys/components/Passkey/PasskeyID/PasskeyID.tsx @@ -1,6 +1,5 @@ -import { Words, type WordsProps } from '@workspace/ui'; - -import { useCopyTextToClipboard } from '~hooks'; +import { useCopyTextToClipboard } from '~client/clipboard/hooks'; +import { Words, type WordsProps } from '~client/ui-kit'; export interface PasskeyIDProps extends Omit, 'variant' | 'onClick'> { value: string; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PasskeyID/index.ts b/packages/common/client/passkeys/components/Passkey/PasskeyID/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PasskeyID/index.ts rename to packages/common/client/passkeys/components/Passkey/PasskeyID/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Provider/Provider.tsx b/packages/common/client/passkeys/components/Passkey/Provider/Provider.tsx similarity index 95% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Provider/Provider.tsx rename to packages/common/client/passkeys/components/Passkey/Provider/Provider.tsx index 93bbcd3..1106a23 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Provider/Provider.tsx +++ b/packages/common/client/passkeys/components/Passkey/Provider/Provider.tsx @@ -1,4 +1,4 @@ -import { ExternalLink, Strong, TextBlock } from '@workspace/ui'; +import { ExternalLink, Strong, TextBlock } from '~client/ui-kit'; import { Caption } from '../Caption'; import { ProviderProfile } from '../ProviderProfile'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Provider/index.ts b/packages/common/client/passkeys/components/Passkey/Provider/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Provider/index.ts rename to packages/common/client/passkeys/components/Passkey/Provider/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/ProviderProfile/ProviderProfile.tsx b/packages/common/client/passkeys/components/Passkey/ProviderProfile/ProviderProfile.tsx similarity index 92% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/ProviderProfile/ProviderProfile.tsx rename to packages/common/client/passkeys/components/Passkey/ProviderProfile/ProviderProfile.tsx index 048228b..599ebcb 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/ProviderProfile/ProviderProfile.tsx +++ b/packages/common/client/passkeys/components/Passkey/ProviderProfile/ProviderProfile.tsx @@ -1,4 +1,4 @@ -import { Box, Words } from '@workspace/ui'; +import { Box, Words } from '~client/ui-kit'; export interface ProviderProfileProps { icon?: string; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/ProviderProfile/index.ts b/packages/common/client/passkeys/components/Passkey/ProviderProfile/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/ProviderProfile/index.ts rename to packages/common/client/passkeys/components/Passkey/ProviderProfile/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/PublicKey.tsx b/packages/common/client/passkeys/components/Passkey/PublicKey/PublicKey.tsx similarity index 83% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/PublicKey.tsx rename to packages/common/client/passkeys/components/Passkey/PublicKey/PublicKey.tsx index 1eeca8a..2c8db50 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/PublicKey.tsx +++ b/packages/common/client/passkeys/components/Passkey/PublicKey/PublicKey.tsx @@ -1,7 +1,7 @@ -import { ExternalLink } from '@workspace/ui'; +import { CopyToClipboardInput } from '~client/clipboard/components'; +import { ExternalLink } from '~client/ui-kit'; import { Caption } from '../Caption'; -import { CopyToClipboardInput } from './CopyToClipboardInput'; export interface PublicKeyProps { value: string; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/index.ts b/packages/common/client/passkeys/components/Passkey/PublicKey/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/PublicKey/index.ts rename to packages/common/client/passkeys/components/Passkey/PublicKey/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/RelativeTime/RelativeTime.tsx b/packages/common/client/passkeys/components/Passkey/RelativeTime/RelativeTime.tsx similarity index 91% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/RelativeTime/RelativeTime.tsx rename to packages/common/client/passkeys/components/Passkey/RelativeTime/RelativeTime.tsx index dc0ebb2..c7dcb6b 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/RelativeTime/RelativeTime.tsx +++ b/packages/common/client/passkeys/components/Passkey/RelativeTime/RelativeTime.tsx @@ -1,7 +1,7 @@ import type { Timestamp } from 'firebase/firestore'; import { FormattedRelativeTime } from 'react-intl'; -import { Words } from '@workspace/ui'; +import { Words } from '~client/ui-kit/components'; export interface RelativeTimeProps { value: Timestamp; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/RelativeTime/index.ts b/packages/common/client/passkeys/components/Passkey/RelativeTime/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/RelativeTime/index.ts rename to packages/common/client/passkeys/components/Passkey/RelativeTime/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/RelayingPartyId/RelayingPartyId.tsx b/packages/common/client/passkeys/components/Passkey/RelayingPartyId/RelayingPartyId.tsx similarity index 95% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/RelayingPartyId/RelayingPartyId.tsx rename to packages/common/client/passkeys/components/Passkey/RelayingPartyId/RelayingPartyId.tsx index 155d001..6c3d3ef 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/RelayingPartyId/RelayingPartyId.tsx +++ b/packages/common/client/passkeys/components/Passkey/RelayingPartyId/RelayingPartyId.tsx @@ -1,4 +1,4 @@ -import { Code, ExternalLink, Strong, TextBlock, Words } from '@workspace/ui'; +import { Code, ExternalLink, Strong, TextBlock, Words } from '~client/ui-kit'; import { Caption } from '../Caption'; diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/RelayingPartyId/index.ts b/packages/common/client/passkeys/components/Passkey/RelayingPartyId/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/RelayingPartyId/index.ts rename to packages/common/client/passkeys/components/Passkey/RelayingPartyId/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Transports/Transports.styles.ts b/packages/common/client/passkeys/components/Passkey/Transports/Transports.styles.ts similarity index 89% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Transports/Transports.styles.ts rename to packages/common/client/passkeys/components/Passkey/Transports/Transports.styles.ts index 1cdf4a9..99a1084 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Transports/Transports.styles.ts +++ b/packages/common/client/passkeys/components/Passkey/Transports/Transports.styles.ts @@ -1,4 +1,4 @@ -import { styled } from '@workspace/ui'; +import { styled } from '~client/ui-kit'; export const Row = styled('div')(({ theme }) => ({ display: 'flex', diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Transports/Transports.tsx b/packages/common/client/passkeys/components/Passkey/Transports/Transports.tsx similarity index 93% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Transports/Transports.tsx rename to packages/common/client/passkeys/components/Passkey/Transports/Transports.tsx index c3718dc..ea99799 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Transports/Transports.tsx +++ b/packages/common/client/passkeys/components/Passkey/Transports/Transports.tsx @@ -1,13 +1,13 @@ -import { Chip, Code, ExternalLink, Icon, InfoTooltip, Space, Strong, TextBlock, Words } from '@workspace/ui'; +import type { AuthenticatorTransportFuture } from '@simplewebauthn/types'; -import type { Passkey } from '~server/types'; +import { Chip, Code, ExternalLink, Icon, InfoTooltip, Space, Strong, TextBlock, Words } from '~client/ui-kit'; import { Caption } from '../Caption'; -import { transportIconsMap, transportTypes, type TransportType } from './constants'; +import { transportIconsMap, transportTypes } from './constants'; import { ChipInner, Row } from './Transports.styles'; export interface TransportsProps { - transports: Passkey['transports']; + transports: AuthenticatorTransportFuture[]; } export const Transports = ({ transports }: TransportsProps) => { @@ -63,7 +63,7 @@ export const Transports = ({ transports }: TransportsProps) => { {transports .filter(transport => transportTypes.has(transport)) .map(transport => { - const { icon, name, description } = transportIconsMap[transport as TransportType]; + const { icon, name, description } = transportIconsMap[transport]; return ( diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Transports/constants/index.ts b/packages/common/client/passkeys/components/Passkey/Transports/constants/index.ts similarity index 80% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Transports/constants/index.ts rename to packages/common/client/passkeys/components/Passkey/Transports/constants/index.ts index 296f278..92afee1 100644 --- a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Transports/constants/index.ts +++ b/packages/common/client/passkeys/components/Passkey/Transports/constants/index.ts @@ -1,8 +1,6 @@ -import { Bluetooth, Cable, Fingerprint, Nfc, QrCode, SdStorage, type SvgIconComponent } from '@workspace/ui/icons'; +import type { AuthenticatorTransportFuture } from '@simplewebauthn/types'; -import type { Passkey } from '~server/types'; - -export type TransportType = Exclude; +import { Bluetooth, Cable, Fingerprint, Nfc, QrCode, SdStorage, type SvgIconComponent } from '~client/ui-kit/icons'; export const transportIconsMap = { ble: { @@ -38,8 +36,13 @@ export const transportIconsMap = { name: 'USB', description: 'The respective authenticator can be contacted over removable USB (e.g. Yubikey).', }, + cable: { + icon: Cable, + name: 'Cable', + description: 'TBD', + }, } as const satisfies Record< - TransportType, + AuthenticatorTransportFuture, { icon: SvgIconComponent; description: string; @@ -47,4 +50,6 @@ export const transportIconsMap = { } >; -export const transportTypes = new Set(Object.keys(transportIconsMap) as TransportType[]); +export const transportTypes = new Set( + Object.keys(transportIconsMap) as AuthenticatorTransportFuture[], +); diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Transports/index.ts b/packages/common/client/passkeys/components/Passkey/Transports/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/Transports/index.ts rename to packages/common/client/passkeys/components/Passkey/Transports/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/index.ts b/packages/common/client/passkeys/components/Passkey/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/components/PasskeysWithFirebasePage/FirebaseExample/Passkeys/Passkey/index.ts rename to packages/common/client/passkeys/components/Passkey/index.ts diff --git a/packages/common/client/passkeys/components/index.ts b/packages/common/client/passkeys/components/index.ts new file mode 100644 index 0000000..94c8d58 --- /dev/null +++ b/packages/common/client/passkeys/components/index.ts @@ -0,0 +1 @@ +export * from './Passkey'; diff --git a/examples/simplewebauthn/src/modules/snackbar/components/SnackbarProvider/SnackbarProvider.styles.ts b/packages/common/client/snackbar/components/SnackbarProvider/SnackbarProvider.styles.ts similarity index 96% rename from examples/simplewebauthn/src/modules/snackbar/components/SnackbarProvider/SnackbarProvider.styles.ts rename to packages/common/client/snackbar/components/SnackbarProvider/SnackbarProvider.styles.ts index 7d597bd..dd15934 100644 --- a/examples/simplewebauthn/src/modules/snackbar/components/SnackbarProvider/SnackbarProvider.styles.ts +++ b/packages/common/client/snackbar/components/SnackbarProvider/SnackbarProvider.styles.ts @@ -1,6 +1,7 @@ -import { styled } from '@mui/material'; import { ToastContainer } from 'react-toastify'; +import { styled } from '~client/ui-kit'; + export const SnackbarkContainer = styled(ToastContainer)(({ theme }) => ({ background: 'transparent', border: 0, diff --git a/examples/simplewebauthn/src/modules/snackbar/components/SnackbarProvider/SnackbarProvider.tsx b/packages/common/client/snackbar/components/SnackbarProvider/SnackbarProvider.tsx similarity index 100% rename from examples/simplewebauthn/src/modules/snackbar/components/SnackbarProvider/SnackbarProvider.tsx rename to packages/common/client/snackbar/components/SnackbarProvider/SnackbarProvider.tsx diff --git a/examples/simplewebauthn/src/modules/snackbar/components/SnackbarProvider/index.ts b/packages/common/client/snackbar/components/SnackbarProvider/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/snackbar/components/SnackbarProvider/index.ts rename to packages/common/client/snackbar/components/SnackbarProvider/index.ts diff --git a/examples/simplewebauthn/src/modules/snackbar/components/index.ts b/packages/common/client/snackbar/components/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/snackbar/components/index.ts rename to packages/common/client/snackbar/components/index.ts diff --git a/examples/simplewebauthn/src/modules/snackbar/hooks/index.ts b/packages/common/client/snackbar/hooks/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/snackbar/hooks/index.ts rename to packages/common/client/snackbar/hooks/index.ts diff --git a/examples/simplewebauthn/src/modules/snackbar/hooks/useSnack.tsx b/packages/common/client/snackbar/hooks/useSnack.tsx similarity index 94% rename from examples/simplewebauthn/src/modules/snackbar/hooks/useSnack.tsx rename to packages/common/client/snackbar/hooks/useSnack.tsx index 6300daf..c4060c3 100644 --- a/examples/simplewebauthn/src/modules/snackbar/hooks/useSnack.tsx +++ b/packages/common/client/snackbar/hooks/useSnack.tsx @@ -1,7 +1,7 @@ import { useCallback, type ReactNode } from 'react'; import { toast as toasts, type ToastOptions } from 'react-toastify'; -import { Alert, alertClasses, Words } from '@workspace/ui'; +import { Alert, alertClasses, Words } from '~client/ui-kit'; export function useSnack() { return useCallback((type: 'success' | 'error', message: ReactNode, options?: ToastOptions) => { diff --git a/packages/ui/src/components/Button/Button.tsx b/packages/common/client/ui-kit/components/Button/Button.tsx similarity index 100% rename from packages/ui/src/components/Button/Button.tsx rename to packages/common/client/ui-kit/components/Button/Button.tsx diff --git a/packages/ui/src/components/Button/index.ts b/packages/common/client/ui-kit/components/Button/index.ts similarity index 100% rename from packages/ui/src/components/Button/index.ts rename to packages/common/client/ui-kit/components/Button/index.ts diff --git a/packages/ui/src/components/Card/Card.styles.tsx b/packages/common/client/ui-kit/components/Card/Card.styles.tsx similarity index 100% rename from packages/ui/src/components/Card/Card.styles.tsx rename to packages/common/client/ui-kit/components/Card/Card.styles.tsx diff --git a/packages/ui/src/components/Card/index.ts b/packages/common/client/ui-kit/components/Card/index.ts similarity index 100% rename from packages/ui/src/components/Card/index.ts rename to packages/common/client/ui-kit/components/Card/index.ts diff --git a/packages/ui/src/components/Code/Code.styles.ts b/packages/common/client/ui-kit/components/Code/Code.styles.ts similarity index 100% rename from packages/ui/src/components/Code/Code.styles.ts rename to packages/common/client/ui-kit/components/Code/Code.styles.ts diff --git a/packages/ui/src/components/Code/index.ts b/packages/common/client/ui-kit/components/Code/index.ts similarity index 100% rename from packages/ui/src/components/Code/index.ts rename to packages/common/client/ui-kit/components/Code/index.ts diff --git a/packages/ui/src/components/ExternalLink/ExternalLink.tsx b/packages/common/client/ui-kit/components/ExternalLink/ExternalLink.tsx similarity index 100% rename from packages/ui/src/components/ExternalLink/ExternalLink.tsx rename to packages/common/client/ui-kit/components/ExternalLink/ExternalLink.tsx diff --git a/packages/ui/src/components/ExternalLink/index.ts b/packages/common/client/ui-kit/components/ExternalLink/index.ts similarity index 100% rename from packages/ui/src/components/ExternalLink/index.ts rename to packages/common/client/ui-kit/components/ExternalLink/index.ts diff --git a/packages/ui/src/components/Features/CategoryName/CategoryName.tsx b/packages/common/client/ui-kit/components/Features/CategoryName/CategoryName.tsx similarity index 100% rename from packages/ui/src/components/Features/CategoryName/CategoryName.tsx rename to packages/common/client/ui-kit/components/Features/CategoryName/CategoryName.tsx diff --git a/packages/ui/src/components/Features/CategoryName/index.ts b/packages/common/client/ui-kit/components/Features/CategoryName/index.ts similarity index 100% rename from packages/ui/src/components/Features/CategoryName/index.ts rename to packages/common/client/ui-kit/components/Features/CategoryName/index.ts diff --git a/packages/ui/src/components/Features/Feature/Feature.tsx b/packages/common/client/ui-kit/components/Features/Feature/Feature.tsx similarity index 100% rename from packages/ui/src/components/Features/Feature/Feature.tsx rename to packages/common/client/ui-kit/components/Features/Feature/Feature.tsx diff --git a/packages/ui/src/components/Features/Feature/index.ts b/packages/common/client/ui-kit/components/Features/Feature/index.ts similarity index 100% rename from packages/ui/src/components/Features/Feature/index.ts rename to packages/common/client/ui-kit/components/Features/Feature/index.ts diff --git a/packages/ui/src/components/Features/Features.styles.ts b/packages/common/client/ui-kit/components/Features/Features.styles.ts similarity index 100% rename from packages/ui/src/components/Features/Features.styles.ts rename to packages/common/client/ui-kit/components/Features/Features.styles.ts diff --git a/packages/ui/src/components/Features/Features.tsx b/packages/common/client/ui-kit/components/Features/Features.tsx similarity index 100% rename from packages/ui/src/components/Features/Features.tsx rename to packages/common/client/ui-kit/components/Features/Features.tsx diff --git a/packages/ui/src/components/Features/index.ts b/packages/common/client/ui-kit/components/Features/index.ts similarity index 100% rename from packages/ui/src/components/Features/index.ts rename to packages/common/client/ui-kit/components/Features/index.ts diff --git a/packages/ui/src/components/Icon/Icon.styles.ts b/packages/common/client/ui-kit/components/Icon/Icon.styles.ts similarity index 100% rename from packages/ui/src/components/Icon/Icon.styles.ts rename to packages/common/client/ui-kit/components/Icon/Icon.styles.ts diff --git a/packages/ui/src/components/Icon/Icon.tsx b/packages/common/client/ui-kit/components/Icon/Icon.tsx similarity index 100% rename from packages/ui/src/components/Icon/Icon.tsx rename to packages/common/client/ui-kit/components/Icon/Icon.tsx diff --git a/packages/ui/src/components/Icon/index.ts b/packages/common/client/ui-kit/components/Icon/index.ts similarity index 100% rename from packages/ui/src/components/Icon/index.ts rename to packages/common/client/ui-kit/components/Icon/index.ts diff --git a/packages/ui/src/components/InfoTooltip/InfoTooltip.styles.tsx b/packages/common/client/ui-kit/components/InfoTooltip/InfoTooltip.styles.tsx similarity index 100% rename from packages/ui/src/components/InfoTooltip/InfoTooltip.styles.tsx rename to packages/common/client/ui-kit/components/InfoTooltip/InfoTooltip.styles.tsx diff --git a/packages/ui/src/components/InfoTooltip/InfoTooltip.tsx b/packages/common/client/ui-kit/components/InfoTooltip/InfoTooltip.tsx similarity index 100% rename from packages/ui/src/components/InfoTooltip/InfoTooltip.tsx rename to packages/common/client/ui-kit/components/InfoTooltip/InfoTooltip.tsx diff --git a/packages/ui/src/components/InfoTooltip/index.ts b/packages/common/client/ui-kit/components/InfoTooltip/index.ts similarity index 100% rename from packages/ui/src/components/InfoTooltip/index.ts rename to packages/common/client/ui-kit/components/InfoTooltip/index.ts diff --git a/packages/ui/src/components/Loader/Loader.styles.ts b/packages/common/client/ui-kit/components/Loader/Loader.styles.ts similarity index 100% rename from packages/ui/src/components/Loader/Loader.styles.ts rename to packages/common/client/ui-kit/components/Loader/Loader.styles.ts diff --git a/packages/ui/src/components/Loader/Loader.tsx b/packages/common/client/ui-kit/components/Loader/Loader.tsx similarity index 100% rename from packages/ui/src/components/Loader/Loader.tsx rename to packages/common/client/ui-kit/components/Loader/Loader.tsx diff --git a/packages/ui/src/components/Loader/index.ts b/packages/common/client/ui-kit/components/Loader/index.ts similarity index 100% rename from packages/ui/src/components/Loader/index.ts rename to packages/common/client/ui-kit/components/Loader/index.ts diff --git a/packages/ui/src/components/MenuItem/MenuItem.styles.ts b/packages/common/client/ui-kit/components/MenuItem/MenuItem.styles.ts similarity index 100% rename from packages/ui/src/components/MenuItem/MenuItem.styles.ts rename to packages/common/client/ui-kit/components/MenuItem/MenuItem.styles.ts diff --git a/packages/ui/src/components/MenuItem/MenuItem.tsx b/packages/common/client/ui-kit/components/MenuItem/MenuItem.tsx similarity index 100% rename from packages/ui/src/components/MenuItem/MenuItem.tsx rename to packages/common/client/ui-kit/components/MenuItem/MenuItem.tsx diff --git a/packages/ui/src/components/MenuItem/index.ts b/packages/common/client/ui-kit/components/MenuItem/index.ts similarity index 100% rename from packages/ui/src/components/MenuItem/index.ts rename to packages/common/client/ui-kit/components/MenuItem/index.ts diff --git a/packages/ui/src/components/PageHeader/PageHeader.tsx b/packages/common/client/ui-kit/components/PageHeader/PageHeader.tsx similarity index 100% rename from packages/ui/src/components/PageHeader/PageHeader.tsx rename to packages/common/client/ui-kit/components/PageHeader/PageHeader.tsx diff --git a/packages/ui/src/components/PageHeader/index.ts b/packages/common/client/ui-kit/components/PageHeader/index.ts similarity index 100% rename from packages/ui/src/components/PageHeader/index.ts rename to packages/common/client/ui-kit/components/PageHeader/index.ts diff --git a/packages/ui/src/components/Words/Words.styles.ts b/packages/common/client/ui-kit/components/Words/Words.styles.ts similarity index 100% rename from packages/ui/src/components/Words/Words.styles.ts rename to packages/common/client/ui-kit/components/Words/Words.styles.ts diff --git a/packages/ui/src/components/Words/Words.tsx b/packages/common/client/ui-kit/components/Words/Words.tsx similarity index 100% rename from packages/ui/src/components/Words/Words.tsx rename to packages/common/client/ui-kit/components/Words/Words.tsx diff --git a/packages/ui/src/components/Words/index.ts b/packages/common/client/ui-kit/components/Words/index.ts similarity index 100% rename from packages/ui/src/components/Words/index.ts rename to packages/common/client/ui-kit/components/Words/index.ts diff --git a/packages/ui/src/components/index.ts b/packages/common/client/ui-kit/components/index.ts similarity index 74% rename from packages/ui/src/components/index.ts rename to packages/common/client/ui-kit/components/index.ts index ffebc9d..027bdae 100644 --- a/packages/ui/src/components/index.ts +++ b/packages/common/client/ui-kit/components/index.ts @@ -1,9 +1,6 @@ export * from './Button'; export * from './Card'; export * from './Code'; -export * from './ExampleDescription'; -export * from './ExampleFrame'; -export * from './ExampleHeader'; export * from './ExternalLink'; export * from './Features'; export * from './Icon'; diff --git a/packages/ui/icons.ts b/packages/common/client/ui-kit/icons.ts similarity index 100% rename from packages/ui/icons.ts rename to packages/common/client/ui-kit/icons.ts diff --git a/packages/common/client/ui-kit/index.ts b/packages/common/client/ui-kit/index.ts new file mode 100644 index 0000000..2c9b982 --- /dev/null +++ b/packages/common/client/ui-kit/index.ts @@ -0,0 +1,2 @@ +export * from './components'; +export * from './mui'; diff --git a/packages/ui/src/mui.ts b/packages/common/client/ui-kit/mui.ts similarity index 100% rename from packages/ui/src/mui.ts rename to packages/common/client/ui-kit/mui.ts diff --git a/packages/ui/src/styles/components/EmotionClient/EmotionClient.tsx b/packages/common/client/ui-kit/styles/components/EmotionClient/EmotionClient.tsx similarity index 100% rename from packages/ui/src/styles/components/EmotionClient/EmotionClient.tsx rename to packages/common/client/ui-kit/styles/components/EmotionClient/EmotionClient.tsx diff --git a/packages/ui/src/styles/components/EmotionClient/index.ts b/packages/common/client/ui-kit/styles/components/EmotionClient/index.ts similarity index 100% rename from packages/ui/src/styles/components/EmotionClient/index.ts rename to packages/common/client/ui-kit/styles/components/EmotionClient/index.ts diff --git a/packages/ui/src/styles/components/ThemeProvider/ThemeProvider.tsx b/packages/common/client/ui-kit/styles/components/ThemeProvider/ThemeProvider.tsx similarity index 100% rename from packages/ui/src/styles/components/ThemeProvider/ThemeProvider.tsx rename to packages/common/client/ui-kit/styles/components/ThemeProvider/ThemeProvider.tsx diff --git a/packages/ui/src/styles/components/ThemeProvider/index.ts b/packages/common/client/ui-kit/styles/components/ThemeProvider/index.ts similarity index 100% rename from packages/ui/src/styles/components/ThemeProvider/index.ts rename to packages/common/client/ui-kit/styles/components/ThemeProvider/index.ts diff --git a/packages/ui/src/styles/index.ts b/packages/common/client/ui-kit/styles/index.ts similarity index 100% rename from packages/ui/src/styles/index.ts rename to packages/common/client/ui-kit/styles/index.ts diff --git a/packages/ui/src/styles/theme/color.ts b/packages/common/client/ui-kit/styles/theme/color.ts similarity index 100% rename from packages/ui/src/styles/theme/color.ts rename to packages/common/client/ui-kit/styles/theme/color.ts diff --git a/packages/ui/src/styles/theme/dimensions.ts b/packages/common/client/ui-kit/styles/theme/dimensions.ts similarity index 100% rename from packages/ui/src/styles/theme/dimensions.ts rename to packages/common/client/ui-kit/styles/theme/dimensions.ts diff --git a/packages/ui/src/styles/theme/index.ts b/packages/common/client/ui-kit/styles/theme/index.ts similarity index 100% rename from packages/ui/src/styles/theme/index.ts rename to packages/common/client/ui-kit/styles/theme/index.ts diff --git a/packages/ui/src/styles/theme/muiTheme.tsx b/packages/common/client/ui-kit/styles/theme/muiTheme.tsx similarity index 100% rename from packages/ui/src/styles/theme/muiTheme.tsx rename to packages/common/client/ui-kit/styles/theme/muiTheme.tsx diff --git a/packages/ui/src/styles/theme/typography.ts b/packages/common/client/ui-kit/styles/theme/typography.ts similarity index 100% rename from packages/ui/src/styles/theme/typography.ts rename to packages/common/client/ui-kit/styles/theme/typography.ts diff --git a/packages/ui/src/styles/utils/createEmotionCache.ts b/packages/common/client/ui-kit/styles/utils/createEmotionCache.ts similarity index 100% rename from packages/ui/src/styles/utils/createEmotionCache.ts rename to packages/common/client/ui-kit/styles/utils/createEmotionCache.ts diff --git a/packages/ui/src/styles/utils/createEmotionCacheWithStyleTags.tsx b/packages/common/client/ui-kit/styles/utils/createEmotionCacheWithStyleTags.tsx similarity index 100% rename from packages/ui/src/styles/utils/createEmotionCacheWithStyleTags.tsx rename to packages/common/client/ui-kit/styles/utils/createEmotionCacheWithStyleTags.tsx diff --git a/packages/ui/src/utils/link.ts b/packages/common/client/ui-kit/utils/link.ts similarity index 100% rename from packages/ui/src/utils/link.ts rename to packages/common/client/ui-kit/utils/link.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/utils/index.ts b/packages/common/client/webauthn/utils/index.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/utils/index.ts rename to packages/common/client/webauthn/utils/index.ts diff --git a/examples/simplewebauthn/src/modules/passkeys/utils/parseWebAuthnError.ts b/packages/common/client/webauthn/utils/parseWebAuthnError.ts similarity index 100% rename from examples/simplewebauthn/src/modules/passkeys/utils/parseWebAuthnError.ts rename to packages/common/client/webauthn/utils/parseWebAuthnError.ts diff --git a/packages/ui/eslint.config.mjs b/packages/common/eslint.config.mjs similarity index 100% rename from packages/ui/eslint.config.mjs rename to packages/common/eslint.config.mjs diff --git a/examples/simplewebauthn/src/logger/index.ts b/packages/common/logger/index.ts similarity index 95% rename from examples/simplewebauthn/src/logger/index.ts rename to packages/common/logger/index.ts index d4b2ed7..9cbcb02 100644 --- a/examples/simplewebauthn/src/logger/index.ts +++ b/packages/common/logger/index.ts @@ -1,6 +1,6 @@ import { createLogger } from '@workspace/logger'; -import { env } from '~env'; +import { env } from '~client/env'; const ignoredErrorMessages = [ 'The operation either timed out or was not allowed.', diff --git a/examples/simplewebauthn/package.json b/packages/common/package.json similarity index 67% rename from examples/simplewebauthn/package.json rename to packages/common/package.json index e16e976..a4c05af 100644 --- a/examples/simplewebauthn/package.json +++ b/packages/common/package.json @@ -1,53 +1,50 @@ { - "name": "simplewebauthn-example", + "name": "@workspace/common", "version": "0.0.1", "type": "module", + "prettier": "@tooling/prettier/config", "scripts": { - "dev": "next dev --turbopack", - "build": "next build", - "start": "next start", - "lint": "eslint-lint --config=eslint.config.mjs './src/**/*.{ts,tsx}'", + "lint": "eslint-lint --config=eslint.config.mjs ./**/*.{ts,tsx}", "lint:fix": "yarn lint --fix", "format": "prettier-format", - "cir-dep": "check-cir-deps ./src" + "cir-dep": "check-cir-deps ." }, "dependencies": { "@ackee/antonio-core": "5.0.0", + "@emotion/react": "11.13.3", + "@emotion/server": "11.11.0", + "@emotion/styled": "11.13.0", "@hookform/resolvers": "3.9.1", + "@mui/icons-material": "6.1.6", + "@mui/lab": "6.0.0-beta.14", + "@mui/material": "6.1.6", "@sentry/nextjs": "8.35.0", "@simplewebauthn/browser": "11.0.0", "@simplewebauthn/server": "11.0.0", "@t3-oss/env-nextjs": "0.11.1", "@tanstack/react-query": "5.59.16", + "@tanstack/react-query-devtools": "5.59.16", "@workspace/logger": "workspace:*", - "@workspace/ui": "workspace:*", "cookie": "1.0.1", "firebase": "11.0.1", "firebase-admin": "12.7.0", "next": "15.0.2", "normalize.css": "8.0.1", + "radash": "12.1.0", "react": "18.3.1", "react-dom": "18.3.1", + "react-hook-form": "7.53.1", "react-intl": "6.8.4", "react-toastify": "10.0.6", "reset.css": "2.0.2", - "string-ts": "2.2.0", "zod": "3.23.8" }, "devDependencies": { - "@tanstack/react-query-devtools": "5.59.16", "@tooling/eslint": "workspace:*", "@tooling/madge": "workspace:*", "@tooling/prettier": "workspace:*", "@tooling/typescript": "workspace:*", "@types/react": "18.3.12", - "@types/react-dom": "18.3.1", - "browserslist-config-custom": "workspace:*", - "type-fest": "4.26.1", - "typescript": "5.6.3" - }, - "prettier": "@tooling/prettier/config", - "browserslist": [ - "extends browserslist-config-custom" - ] + "@types/react-dom": "18.3.1" + } } diff --git a/examples/simplewebauthn/src/server/config/firebase.ts b/packages/common/server/config/firebase.ts similarity index 88% rename from examples/simplewebauthn/src/server/config/firebase.ts rename to packages/common/server/config/firebase.ts index 5af07cd..f3fb6fa 100644 --- a/examples/simplewebauthn/src/server/config/firebase.ts +++ b/packages/common/server/config/firebase.ts @@ -39,6 +39,10 @@ export const getAdminApp = () => { return adminApp; }; -export const db = () => getFirestore(getAdminApp()); +export const db = () => { + const app = getAdminApp(); + + return env.FIREBASE_DB_ID ? getFirestore(app, env.FIREBASE_DB_ID) : getFirestore(app); +}; export const auth = () => getAuth(getAdminApp()); diff --git a/examples/simplewebauthn/src/server/constants/collections.ts b/packages/common/server/constants/collections.ts similarity index 100% rename from examples/simplewebauthn/src/server/constants/collections.ts rename to packages/common/server/constants/collections.ts diff --git a/examples/simplewebauthn/src/server/constants/relyingParty.ts b/packages/common/server/constants/relyingParty.ts similarity index 100% rename from examples/simplewebauthn/src/server/constants/relyingParty.ts rename to packages/common/server/constants/relyingParty.ts diff --git a/examples/simplewebauthn/src/server/env/index.ts b/packages/common/server/env/index.ts similarity index 84% rename from examples/simplewebauthn/src/server/env/index.ts rename to packages/common/server/env/index.ts index 6fed1cc..db4b989 100644 --- a/examples/simplewebauthn/src/server/env/index.ts +++ b/packages/common/server/env/index.ts @@ -12,9 +12,11 @@ export const env = z FIREBASE_PROJECT_ID: z.string(), FIREBASE_PRIVATE_KEY: z.string(), FIREBASE_CLIENT_EMAIL: z.string(), + FIREBASE_DB_ID: z.string().optional(), }) .parse({ FIREBASE_PROJECT_ID: process.env.FIREBASE_PROJECT_ID, FIREBASE_PRIVATE_KEY: process.env.FIREBASE_PRIVATE_KEY, FIREBASE_CLIENT_EMAIL: process.env.FIREBASE_CLIENT_EMAIL, + FIREBASE_DB_ID: process.env.FIREBASE_DB_ID, }); diff --git a/examples/simplewebauthn/src/server/scripts/deleteAllUsers.ts b/packages/common/server/scripts/deleteAllUsers.ts similarity index 100% rename from examples/simplewebauthn/src/server/scripts/deleteAllUsers.ts rename to packages/common/server/scripts/deleteAllUsers.ts diff --git a/examples/simplewebauthn/src/server/services/aaguid/combined_aaguid.json b/packages/common/server/services/aaguid/combined_aaguid.json similarity index 100% rename from examples/simplewebauthn/src/server/services/aaguid/combined_aaguid.json rename to packages/common/server/services/aaguid/combined_aaguid.json diff --git a/examples/simplewebauthn/src/server/services/aaguid/index.ts b/packages/common/server/services/aaguid/index.ts similarity index 100% rename from examples/simplewebauthn/src/server/services/aaguid/index.ts rename to packages/common/server/services/aaguid/index.ts diff --git a/examples/simplewebauthn/src/server/services/auth/index.ts b/packages/common/server/services/auth/index.ts similarity index 100% rename from examples/simplewebauthn/src/server/services/auth/index.ts rename to packages/common/server/services/auth/index.ts diff --git a/examples/simplewebauthn/src/server/services/challenge-session/cookies.ts b/packages/common/server/services/challenge-session/cookies.ts similarity index 97% rename from examples/simplewebauthn/src/server/services/challenge-session/cookies.ts rename to packages/common/server/services/challenge-session/cookies.ts index 4714e98..45cfc2a 100644 --- a/examples/simplewebauthn/src/server/services/challenge-session/cookies.ts +++ b/packages/common/server/services/challenge-session/cookies.ts @@ -34,7 +34,7 @@ const commonCookieOptions = { /** * This cookie is only used for the authentication endpoints. */ - path: '/api/authentication/with-firebase', + path: '/api/webauthn', priority: 'high', } as const satisfies DeleteCookieProps; diff --git a/examples/simplewebauthn/src/server/services/challenge-session/db.ts b/packages/common/server/services/challenge-session/db.ts similarity index 96% rename from examples/simplewebauthn/src/server/services/challenge-session/db.ts rename to packages/common/server/services/challenge-session/db.ts index b242169..7ac5562 100644 --- a/examples/simplewebauthn/src/server/services/challenge-session/db.ts +++ b/packages/common/server/services/challenge-session/db.ts @@ -1,6 +1,6 @@ import { db } from '~server/config/firebase'; import { collections } from '~server/constants/collections'; -import type { ChallengeSession } from '~server/types'; +import type { ChallengeSession } from '~types'; export async function setChallengeSession(data: ChallengeSession) { await db().collection(collections.ChallengeSessions).doc(data.id).set(data); diff --git a/examples/simplewebauthn/src/server/services/challenge-session/index.ts b/packages/common/server/services/challenge-session/index.ts similarity index 96% rename from examples/simplewebauthn/src/server/services/challenge-session/index.ts rename to packages/common/server/services/challenge-session/index.ts index 81706bb..8295c32 100644 --- a/examples/simplewebauthn/src/server/services/challenge-session/index.ts +++ b/packages/common/server/services/challenge-session/index.ts @@ -1,9 +1,9 @@ import type { NextApiRequest, NextApiResponse } from 'next'; import { bufferToBase64URLString } from '@simplewebauthn/browser'; -import { env } from '~env'; -import type { ChallengeSession } from '~server/types'; +import { env } from '~client/env'; import { getRpId } from '~server/utils/relyingParty'; +import type { ChallengeSession } from '~types'; import { deleteSessionIdCookie, getSessionIdCookie, setSessionIdCookie } from './cookies'; import { deleteChallengeSession, getChallengeSession, setChallengeSession } from './db'; diff --git a/examples/simplewebauthn/src/server/services/passkeys/index.ts b/packages/common/server/services/passkeys/index.ts similarity index 97% rename from examples/simplewebauthn/src/server/services/passkeys/index.ts rename to packages/common/server/services/passkeys/index.ts index fc04619..972382d 100644 --- a/examples/simplewebauthn/src/server/services/passkeys/index.ts +++ b/packages/common/server/services/passkeys/index.ts @@ -2,7 +2,7 @@ import { FieldValue } from 'firebase-admin/firestore'; import { db } from '~server/config/firebase'; import { collections } from '~server/constants/collections'; -import type { Passkey } from '~server/types'; +import type { Passkey } from '~types'; export type AddPasskeyProps = Omit; diff --git a/examples/simplewebauthn/src/server/services/users/index.ts b/packages/common/server/services/users/index.ts similarity index 98% rename from examples/simplewebauthn/src/server/services/users/index.ts rename to packages/common/server/services/users/index.ts index f390142..8967b3c 100644 --- a/examples/simplewebauthn/src/server/services/users/index.ts +++ b/packages/common/server/services/users/index.ts @@ -3,7 +3,7 @@ import type { VerifiedRegistrationResponse } from '@simplewebauthn/server'; import { db } from '~server/config/firebase'; import { collections } from '~server/constants/collections'; -import type { Passkey, User } from '~server/types'; +import type { Passkey, User } from '~types'; import { getPasskeyProvider } from '../aaguid'; import { createAuthUser } from '../auth'; diff --git a/examples/simplewebauthn/src/server/utils/cookies.ts b/packages/common/server/utils/cookies.ts similarity index 100% rename from examples/simplewebauthn/src/server/utils/cookies.ts rename to packages/common/server/utils/cookies.ts diff --git a/packages/common/server/utils/index.ts b/packages/common/server/utils/index.ts new file mode 100644 index 0000000..3345609 --- /dev/null +++ b/packages/common/server/utils/index.ts @@ -0,0 +1,5 @@ +export * from './cookies'; +export * from './parseAndVerifyIdToken'; +export * from './parseAuthenticationResponse'; +export * from './parseRegistrationResponse'; +export * from './relyingParty'; diff --git a/examples/simplewebauthn/src/server/utils/parseAndVerifyIdToken.ts b/packages/common/server/utils/parseAndVerifyIdToken.ts similarity index 88% rename from examples/simplewebauthn/src/server/utils/parseAndVerifyIdToken.ts rename to packages/common/server/utils/parseAndVerifyIdToken.ts index 7ea99a3..92ae496 100644 --- a/examples/simplewebauthn/src/server/utils/parseAndVerifyIdToken.ts +++ b/packages/common/server/utils/parseAndVerifyIdToken.ts @@ -1,4 +1,5 @@ -import { logger } from '~logger'; +import { logger } from '@workspace/common/logger'; + import { auth } from '~server/config/firebase'; export async function parseAndVerifyIdToken(authorizationHeader: string | undefined) { diff --git a/examples/simplewebauthn/src/server/utils/parseAuthenticationResponse.ts b/packages/common/server/utils/parseAuthenticationResponse.ts similarity index 100% rename from examples/simplewebauthn/src/server/utils/parseAuthenticationResponse.ts rename to packages/common/server/utils/parseAuthenticationResponse.ts diff --git a/examples/simplewebauthn/src/server/utils/parseRegistrationResponse.ts b/packages/common/server/utils/parseRegistrationResponse.ts similarity index 95% rename from examples/simplewebauthn/src/server/utils/parseRegistrationResponse.ts rename to packages/common/server/utils/parseRegistrationResponse.ts index 9590ffe..34a3120 100644 --- a/examples/simplewebauthn/src/server/utils/parseRegistrationResponse.ts +++ b/packages/common/server/utils/parseRegistrationResponse.ts @@ -7,7 +7,7 @@ import { } from '@simplewebauthn/server/helpers'; import type { RegistrationResponseJSON } from '@simplewebauthn/types'; -import { logger } from '~logger'; +import { logger } from '@workspace/common/logger'; /** * An example of how to all data parse the registration response. diff --git a/examples/simplewebauthn/src/server/utils/relyingParty.ts b/packages/common/server/utils/relyingParty.ts similarity index 100% rename from examples/simplewebauthn/src/server/utils/relyingParty.ts rename to packages/common/server/utils/relyingParty.ts diff --git a/packages/common/tsconfig.json b/packages/common/tsconfig.json new file mode 100644 index 0000000..4e55a3d --- /dev/null +++ b/packages/common/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "@tooling/typescript/nextjs", + "compilerOptions": { + "baseUrl": ".", + "paths": { + "~*": [ + "./*" + ], + } + }, + "include": [ + "**/*.ts", + "**/*.tsx", + "client/env/env.mjs", + ] +} \ No newline at end of file diff --git a/examples/simplewebauthn/src/server/types/index.ts b/packages/common/types/index.ts similarity index 94% rename from examples/simplewebauthn/src/server/types/index.ts rename to packages/common/types/index.ts index 72ecdf4..d2abce6 100644 --- a/examples/simplewebauthn/src/server/types/index.ts +++ b/packages/common/types/index.ts @@ -4,7 +4,13 @@ import type { Timestamp } from 'firebase/firestore'; import type { PasskeyProvider } from '~server/services/aaguid'; export type Passkey = { + /** + * Passkey ID + * - Used as primary key + * - Generated by Firestore + */ id: string; + /** * User ID generated by Firebase * Used as primary key @@ -19,7 +25,7 @@ export type Passkey = { /** * Credential Public Key as a base64url encoded string */ - credentialPublicKey: string; + credentialPublicKey: Base64URLString; /** * How many times the credential has been used diff --git a/packages/logger/package.json b/packages/logger/package.json index f6caccc..f19e5e8 100644 --- a/packages/logger/package.json +++ b/packages/logger/package.json @@ -3,7 +3,7 @@ "version": "0.0.1", "type": "module", "peerDependencies": { - "next": "14.x", + "next": "15.x", "react": "18.x" }, "dependencies": { @@ -18,6 +18,6 @@ "prettier": "@tooling/prettier/config", "scripts": { "format": "prettier-format --write ./*.ts", - "lint": "eslint-lint --config eslint.config.mjs './**/*.ts'" + "lint": "eslint-lint --config eslint.config.mjs ./**/*.ts" } } diff --git a/packages/ui/.storybook/globals.css b/packages/ui/.storybook/globals.css deleted file mode 100644 index 65adce8..0000000 --- a/packages/ui/.storybook/globals.css +++ /dev/null @@ -1,3 +0,0 @@ -body { - background: #F1F3F5; -} \ No newline at end of file diff --git a/packages/ui/.storybook/main.ts b/packages/ui/.storybook/main.ts deleted file mode 100644 index 7cfaf82..0000000 --- a/packages/ui/.storybook/main.ts +++ /dev/null @@ -1,9 +0,0 @@ -import type { StorybookConfig } from '@storybook/nextjs'; - -const config: StorybookConfig = { - framework: '@storybook/nextjs', - stories: ['../src/**/*.stories.@(js|jsx|ts|tsx)'], - addons: ['@storybook/addon-essentials', '@storybook/addon-interactions'], -}; - -export default config; diff --git a/packages/ui/.storybook/preview.tsx b/packages/ui/.storybook/preview.tsx deleted file mode 100644 index 929a926..0000000 --- a/packages/ui/.storybook/preview.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import React from 'react'; -import { Preview } from '@storybook/react'; - -import { ThemeProvider } from '../src/styles/components/ThemeProvider'; - -import './globals.css'; - -const preview: Preview = { - parameters: { - actions: { argTypesRegex: '^on[A-Z].*' }, - }, - decorators: [ - Story => ( - - - - ), - ], -}; - -export default preview; diff --git a/packages/ui/index.ts b/packages/ui/index.ts deleted file mode 100644 index 8420b10..0000000 --- a/packages/ui/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './src'; diff --git a/packages/ui/next-env.d.ts b/packages/ui/next-env.d.ts deleted file mode 100644 index 4f11a03..0000000 --- a/packages/ui/next-env.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -/// -/// - -// NOTE: This file should not be edited -// see https://nextjs.org/docs/basic-features/typescript for more information. diff --git a/packages/ui/package.json b/packages/ui/package.json deleted file mode 100644 index 4346841..0000000 --- a/packages/ui/package.json +++ /dev/null @@ -1,44 +0,0 @@ -{ - "name": "@workspace/ui", - "version": "0.0.1", - "type": "module", - "scripts": { - "storybook": "storybook dev -p 6006", - "storybook:build": "storybook build", - "cir-dep": "check-cir-deps ./src", - "format": "prettier-format", - "lint": "eslint-lint --config eslint.config.mjs './src/**/*.{ts,tsx}'" - }, - "peerDependencies": { - "react": "18.x", - "react-dom": "18.x", - "typescript": "5.x" - }, - "dependencies": { - "@emotion/react": "11.13.3", - "@emotion/server": "11.11.0", - "@emotion/styled": "11.13.0", - "@mui/icons-material": "6.1.6", - "@mui/lab": "6.0.0-beta.14", - "@mui/material": "6.1.6", - "@workspace/logger": "workspace:*", - "radash": "12.1.0", - "react-hook-form": "7.53.1" - }, - "devDependencies": { - "@storybook/addon-actions": "8.3.6", - "@storybook/addon-essentials": "8.3.6", - "@storybook/addon-interactions": "8.3.6", - "@storybook/nextjs": "8.3.6", - "@storybook/react": "8.3.6", - "@tooling/eslint": "workspace:*", - "@tooling/madge": "workspace:*", - "@tooling/prettier": "workspace:*", - "@tooling/typescript": "workspace:*", - "@types/react": "18.3.12", - "next": "14.2.16", - "storybook": "8.3.6", - "typescript": "5.6.3" - }, - "prettier": "@tooling/prettier/config" -} diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts deleted file mode 100644 index 907c420..0000000 --- a/packages/ui/src/index.ts +++ /dev/null @@ -1,5 +0,0 @@ -export * from './components'; -export * from './modules/form/components'; -export * from './modules/form/types'; -export * from './mui'; -export * from './styles'; diff --git a/packages/ui/src/modules/form/components/index.ts b/packages/ui/src/modules/form/components/index.ts deleted file mode 100644 index 1bd4e93..0000000 --- a/packages/ui/src/modules/form/components/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './fields'; -export * from './FieldsStack'; -export * from './FormError'; -export * from './inputs'; diff --git a/packages/ui/src/modules/form/components/inputs/Select/Select.stories.tsx b/packages/ui/src/modules/form/components/inputs/Select/Select.stories.tsx deleted file mode 100644 index 0bd28a4..0000000 --- a/packages/ui/src/modules/form/components/inputs/Select/Select.stories.tsx +++ /dev/null @@ -1,51 +0,0 @@ -import type { Meta, StoryObj } from '@storybook/react'; - -import { logger } from '@workspace/logger'; - -import { Select } from './Select'; - -const meta = { - title: 'UI/Form/Select', - component: Select, - argTypes: { - options: { - control: { type: 'object' }, - }, - defaultValue: { - control: { type: 'text' }, - }, - error: { - control: { type: 'boolean' }, - }, - open: { - control: { type: 'boolean' }, - }, - fullWidth: { - control: { type: 'boolean' }, - }, - }, -} satisfies Meta; - -export default meta; - -type Story = StoryObj; -export const Primary: Story = { - args: { - options: [ - { value: 'Member', label: 'Member' }, - { value: 'Admin', label: 'Admin' }, - { value: 'Tvuj strejda', label: 'Tvuj strejda' }, - { value: 'Host', label: 'Host' }, - { value: 'nevim', label: 'nevim' }, - ], - defaultValue: 'Admin', - onChange: (e: any) => { - logger.info(e); - }, - error: false, - open: false, - fullWidth: false, - }, - - render: args =>