From 6464920a223a10807f13288459c031d274a7caf7 Mon Sep 17 00:00:00 2001
From: aeneasr <3372410+aeneasr@users.noreply.github.com>
Date: Tue, 15 Oct 2024 10:29:34 +0200
Subject: [PATCH] refactor: flatten project config and make arguments optional
BREAKING CHANGES: The configuration `OryClientConfiguration` has changed. Everything previously under the `project` key is now at the root level and optional:
```patch
{
sdk: { ... },
- project: {
- registration_enabled: true,
- ...
- }
registration_enabled: true,
...
}
```
---
package-lock.json | 257 ++++++++++++++++--
packages/elements-react/package.json | 1 +
.../src/components/card/card-two-step.tsx | 2 +-
.../src/tests/jest/test-utils.tsx | 2 -
.../theme/default/components/card/footer.tsx | 2 +-
.../theme/default/components/form/label.tsx | 4 +-
.../src/util/clientConfiguration.ts | 69 ++++-
7 files changed, 300 insertions(+), 37 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index b473555d6..b4ceef48b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -12674,7 +12674,6 @@
"resolved": "https://registry.npmjs.org/@testing-library/react/-/react-16.0.1.tgz",
"integrity": "sha512-dSmwJVtJXmku+iocRhWOUFbrERC76TX2Mnf0ATODz8brzAZrMBbzLwQixlBSanZxR6LddK3eiwpSFZgDET1URg==",
"dev": true,
- "license": "MIT",
"dependencies": {
"@babel/runtime": "^7.12.5"
},
@@ -34210,6 +34209,7 @@
"devDependencies": {
"@hookform/devtools": "^4.3.1",
"@svgr/plugin-svgo": "^8.1.0",
+ "@testing-library/react": "^16.0.1",
"@types/lodash.merge": "4.6.9",
"esbuild-plugin-svgr": "^2.1.0",
"eslint-plugin-react": "7.37.0",
@@ -34695,6 +34695,220 @@
"integrity": "sha512-oY5cIuzqoHYaZQKA2N40L76R2RPl2C1RzuNJZFvBxRTtC+hage2ejQI6hBCGfiChkoZ8tTsyI5vErE2KWejFXQ==",
"license": "Apache-2.0"
},
+ "packages/elements-react/node_modules/@rollup/rollup-android-arm-eabi": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.24.0.tgz",
+ "integrity": "sha512-Q6HJd7Y6xdB48x8ZNVDOqsbh2uByBhgK8PiQgPhwkIw/HC/YX5Ghq2mQY5sRMZWHb3VsFkWooUVOZHKr7DmDIA==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "android"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-android-arm64": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.24.0.tgz",
+ "integrity": "sha512-ijLnS1qFId8xhKjT81uBHuuJp2lU4x2yxa4ctFPtG+MqEE6+C5f/+X/bStmxapgmwLwiL3ih122xv8kVARNAZA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "android"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-darwin-arm64": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.24.0.tgz",
+ "integrity": "sha512-bIv+X9xeSs1XCk6DVvkO+S/z8/2AMt/2lMqdQbMrmVpgFvXlmde9mLcbQpztXm1tajC3raFDqegsH18HQPMYtA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "darwin"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-darwin-x64": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.24.0.tgz",
+ "integrity": "sha512-X6/nOwoFN7RT2svEQWUsW/5C/fYMBe4fnLK9DQk4SX4mgVBiTA9h64kjUYPvGQ0F/9xwJ5U5UfTbl6BEjaQdBQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "darwin"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-linux-arm-gnueabihf": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.24.0.tgz",
+ "integrity": "sha512-0KXvIJQMOImLCVCz9uvvdPgfyWo93aHHp8ui3FrtOP57svqrF/roSSR5pjqL2hcMp0ljeGlU4q9o/rQaAQ3AYA==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-linux-arm-musleabihf": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.24.0.tgz",
+ "integrity": "sha512-it2BW6kKFVh8xk/BnHfakEeoLPv8STIISekpoF+nBgWM4d55CZKc7T4Dx1pEbTnYm/xEKMgy1MNtYuoA8RFIWw==",
+ "cpu": [
+ "arm"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-linux-arm64-gnu": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.24.0.tgz",
+ "integrity": "sha512-i0xTLXjqap2eRfulFVlSnM5dEbTVque/3Pi4g2y7cxrs7+a9De42z4XxKLYJ7+OhE3IgxvfQM7vQc43bwTgPwA==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-linux-arm64-musl": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.24.0.tgz",
+ "integrity": "sha512-9E6MKUJhDuDh604Qco5yP/3qn3y7SLXYuiC0Rpr89aMScS2UAmK1wHP2b7KAa1nSjWJc/f/Lc0Wl1L47qjiyQw==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-linux-powerpc64le-gnu": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.24.0.tgz",
+ "integrity": "sha512-2XFFPJ2XMEiF5Zi2EBf4h73oR1V/lycirxZxHZNc93SqDN/IWhYYSYj8I9381ikUFXZrz2v7r2tOVk2NBwxrWw==",
+ "cpu": [
+ "ppc64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-linux-riscv64-gnu": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.24.0.tgz",
+ "integrity": "sha512-M3Dg4hlwuntUCdzU7KjYqbbd+BLq3JMAOhCKdBE3TcMGMZbKkDdJ5ivNdehOssMCIokNHFOsv7DO4rlEOfyKpg==",
+ "cpu": [
+ "riscv64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-linux-s390x-gnu": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.24.0.tgz",
+ "integrity": "sha512-mjBaoo4ocxJppTorZVKWFpy1bfFj9FeCMJqzlMQGjpNPY9JwQi7OuS1axzNIk0nMX6jSgy6ZURDZ2w0QW6D56g==",
+ "cpu": [
+ "s390x"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-linux-x64-gnu": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.24.0.tgz",
+ "integrity": "sha512-ZXFk7M72R0YYFN5q13niV0B7G8/5dcQ9JDp8keJSfr3GoZeXEoMHP/HlvqROA3OMbMdfr19IjCeNAnPUG93b6A==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-linux-x64-musl": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.24.0.tgz",
+ "integrity": "sha512-w1i+L7kAXZNdYl+vFvzSZy8Y1arS7vMgIy8wusXJzRrPyof5LAb02KGr1PD2EkRcl73kHulIID0M501lN+vobQ==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "linux"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-win32-arm64-msvc": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.24.0.tgz",
+ "integrity": "sha512-VXBrnPWgBpVDCVY6XF3LEW0pOU51KbaHhccHw6AS6vBWIC60eqsH19DAeeObl+g8nKAz04QFdl/Cefta0xQtUQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-win32-ia32-msvc": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.24.0.tgz",
+ "integrity": "sha512-xrNcGDU0OxVcPTH/8n/ShH4UevZxKIO6HJFK0e15XItZP2UcaiLFd5kiX7hJnqCbSztUF8Qot+JWBC/QXRPYWQ==",
+ "cpu": [
+ "ia32"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "packages/elements-react/node_modules/@rollup/rollup-win32-x64-msvc": {
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.24.0.tgz",
+ "integrity": "sha512-fbMkAF7fufku0N2dE5TBXcNlg0pt0cJue4xBRE2Qc5Vqikxr4VCgKj/ht6SMdFcOacVA9rqF70APJ8RN/4vMJw==",
+ "cpu": [
+ "x64"
+ ],
+ "dev": true,
+ "optional": true,
+ "os": [
+ "win32"
+ ]
+ },
+ "packages/elements-react/node_modules/@types/estree": {
+ "version": "1.0.6",
+ "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz",
+ "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==",
+ "dev": true
+ },
"packages/elements-react/node_modules/doctrine": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz",
@@ -34924,13 +35138,12 @@
}
},
"packages/elements-react/node_modules/rollup": {
- "version": "4.21.2",
- "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.21.2.tgz",
- "integrity": "sha512-e3TapAgYf9xjdLvKQCkQTnbTKd4a6jwlpQSJJFokHGaX2IVjoEqkIIhiQfqsi0cdwlOD+tQGuOd5AJkc5RngBw==",
+ "version": "4.24.0",
+ "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.24.0.tgz",
+ "integrity": "sha512-DOmrlGSXNk1DM0ljiQA+i+o0rSLhtii1je5wgk60j49d1jHT5YYttBv1iWOnYSTG+fZZESUOSNiAl89SIet+Cg==",
"dev": true,
- "license": "MIT",
"dependencies": {
- "@types/estree": "1.0.5"
+ "@types/estree": "1.0.6"
},
"bin": {
"rollup": "dist/bin/rollup"
@@ -34940,22 +35153,22 @@
"npm": ">=8.0.0"
},
"optionalDependencies": {
- "@rollup/rollup-android-arm-eabi": "4.21.2",
- "@rollup/rollup-android-arm64": "4.21.2",
- "@rollup/rollup-darwin-arm64": "4.21.2",
- "@rollup/rollup-darwin-x64": "4.21.2",
- "@rollup/rollup-linux-arm-gnueabihf": "4.21.2",
- "@rollup/rollup-linux-arm-musleabihf": "4.21.2",
- "@rollup/rollup-linux-arm64-gnu": "4.21.2",
- "@rollup/rollup-linux-arm64-musl": "4.21.2",
- "@rollup/rollup-linux-powerpc64le-gnu": "4.21.2",
- "@rollup/rollup-linux-riscv64-gnu": "4.21.2",
- "@rollup/rollup-linux-s390x-gnu": "4.21.2",
- "@rollup/rollup-linux-x64-gnu": "4.21.2",
- "@rollup/rollup-linux-x64-musl": "4.21.2",
- "@rollup/rollup-win32-arm64-msvc": "4.21.2",
- "@rollup/rollup-win32-ia32-msvc": "4.21.2",
- "@rollup/rollup-win32-x64-msvc": "4.21.2",
+ "@rollup/rollup-android-arm-eabi": "4.24.0",
+ "@rollup/rollup-android-arm64": "4.24.0",
+ "@rollup/rollup-darwin-arm64": "4.24.0",
+ "@rollup/rollup-darwin-x64": "4.24.0",
+ "@rollup/rollup-linux-arm-gnueabihf": "4.24.0",
+ "@rollup/rollup-linux-arm-musleabihf": "4.24.0",
+ "@rollup/rollup-linux-arm64-gnu": "4.24.0",
+ "@rollup/rollup-linux-arm64-musl": "4.24.0",
+ "@rollup/rollup-linux-powerpc64le-gnu": "4.24.0",
+ "@rollup/rollup-linux-riscv64-gnu": "4.24.0",
+ "@rollup/rollup-linux-s390x-gnu": "4.24.0",
+ "@rollup/rollup-linux-x64-gnu": "4.24.0",
+ "@rollup/rollup-linux-x64-musl": "4.24.0",
+ "@rollup/rollup-win32-arm64-msvc": "4.24.0",
+ "@rollup/rollup-win32-ia32-msvc": "4.24.0",
+ "@rollup/rollup-win32-x64-msvc": "4.24.0",
"fsevents": "~2.3.2"
}
},
diff --git a/packages/elements-react/package.json b/packages/elements-react/package.json
index 7dac6e98c..abbed64ed 100644
--- a/packages/elements-react/package.json
+++ b/packages/elements-react/package.json
@@ -43,6 +43,7 @@
"devDependencies": {
"@hookform/devtools": "^4.3.1",
"@svgr/plugin-svgo": "^8.1.0",
+ "@testing-library/react": "^16.0.1",
"@types/lodash.merge": "4.6.9",
"esbuild-plugin-svgr": "^2.1.0",
"eslint-plugin-react": "7.37.0",
diff --git a/packages/elements-react/src/components/card/card-two-step.tsx b/packages/elements-react/src/components/card/card-two-step.tsx
index 9dba5661f..498bad6b8 100644
--- a/packages/elements-react/src/components/card/card-two-step.tsx
+++ b/packages/elements-react/src/components/card/card-two-step.tsx
@@ -89,7 +89,7 @@ export function OryTwoStepCard() {
{step === ProcessStep.ChooseAuthMethod && (
<>
{flowType === FlowType.Login && (
-
+
)}
{options.map((option) => (
{isPassword &&
- config.project.recovery_enabled &&
+ (config.recovery_enabled ?? true) &&
flowType === FlowType.Login && (
// TODO: make it possible to override with a custom component
{intl.formatMessage({
diff --git a/packages/elements-react/src/util/clientConfiguration.ts b/packages/elements-react/src/util/clientConfiguration.ts
index 1ce6e1e28..1a5fb0391 100644
--- a/packages/elements-react/src/util/clientConfiguration.ts
+++ b/packages/elements-react/src/util/clientConfiguration.ts
@@ -16,21 +16,72 @@ export type OryClientConfiguration = {
stylesheet?: string
+ /**
+ * An optional favicon URL to display in the UI.
+ */
favicon?: string
+ /**
+ * The SDK configuration.
+ */
sdk: {
+ /**
+ * Your SDK URL.
+ *
+ * You can find it here: https://console.ory.sh/projects/current/settings
+ */
url: string
+
+ /**
+ * Optional SDK configuration parameters.
+ */
options?: Partial
}
- project: {
- registration_enabled: boolean
- verification_enabled: boolean
- recovery_enabled: boolean
+ /**
+ * Enable or disable registration.
+ *
+ * Defaults to true.
+ */
+ registration_enabled?: boolean
+ /**
+ * Enable or disable verification.
+ *
+ * Defaults to true.
+ */
+ verification_enabled?: boolean
+ /**
+ * Enable or disable verification.
+ *
+ * Defaults to true.
+ */
+ recovery_enabled?: boolean
- recovery_ui_url: string
- registration_ui_url: string
- verification_ui_url: string
- login_ui_url: string
- }
+ /**
+ * The URL to redirect to when the user wants to recover their account.
+ *
+ * Defaults to `/recovery`.
+ */
+ recovery_ui_url?: string
+
+ /**
+ * The URL to redirect to when the user wants to register.
+ *
+ * Defaults to `/registration`.
+ */
+ registration_ui_url?: string
+
+ /**
+ * The URL to redirect to when the user wants to verify their account.
+ *
+ * Defaults to `/verification`.
+ */
+ verification_ui_url?: string
+
+ /**
+ * The URL to redirect to when the user wants to log in.
+ *
+ * Defaults to `/login`.
+ */
+ login_ui_url?: string
}