@ory/elements-react 1.0.0-next.1 → 1.0.0-next.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.eslintrc.js CHANGED
@@ -39,6 +39,8 @@ module.exports = {
39
39
  caughtErrorsIgnorePattern: "^_",
40
40
  },
41
41
  ],
42
+ // TODO(jonas): prettier and eslint sometimes disagree about this
43
+ "no-extra-semi": "off",
42
44
  },
43
45
  env: {
44
46
  jest: true,
@@ -0,0 +1,3 @@
1
+ # Review comments generated by i18n-ally. Please commit this file.
2
+
3
+ {}
@@ -0,0 +1,4 @@
1
+ {
2
+ "i18n-ally.localesPaths": ["src/locales", "src/util/i18n"],
3
+ "i18n-ally.keystyle": "flat"
4
+ }
package/CHANGELOG.md ADDED
@@ -0,0 +1,115 @@
1
+ ## 1.0.0-next.11 (2024-10-22)
2
+
3
+ Breaking Changes: This update includes breaking changes to the naming of some variables and functions. Please refer to [Advisory: ory elements‐react upgrade guide to v1.0.0‐next.11](https://github.com/ory/elements/wiki/Advisory:-ory-elements%E2%80%90react-upgrade-guide-to-v1.0.0%E2%80%90next.11) for more information.
4
+
5
+
6
+ ### 🚀 Features
7
+
8
+ - add elements v1 packages
9
+
10
+ - add useSession hook
11
+
12
+ ### ❤️ Thank You
13
+
14
+ - Jonas Hungershausen
15
+
16
+ ## 1.0.0-next.10 (2024-10-14)
17
+
18
+
19
+ ### 🩹 Fixes
20
+
21
+ - add missing translations in all places
22
+
23
+
24
+ ### ❤️ Thank You
25
+
26
+ - Jonas Hungershausen
27
+
28
+ ## 1.0.0-next.9 (2024-10-10)
29
+
30
+
31
+ ### 🩹 Fixes
32
+
33
+ - add missing swedish translations
34
+
35
+
36
+ ### ❤️ Thank You
37
+
38
+ - Jonas Hungershausen
39
+
40
+ ## 1.0.0-next.8 (2024-10-07)
41
+
42
+
43
+ ### 🩹 Fixes
44
+
45
+ - ⚠️ remove ory-default-theme class
46
+
47
+ - remove capitalize class from messages
48
+
49
+
50
+ #### ⚠️ Breaking Changes
51
+
52
+ - ⚠️ remove ory-default-theme class
53
+
54
+ ### ❤️ Thank You
55
+
56
+ - Jonas Hungershausen
57
+
58
+ ## 1.0.0-next.7 (2024-09-27)
59
+
60
+ ### 🚀 Features
61
+
62
+ - add two-step login card
63
+
64
+ ### 🩹 Fixes
65
+
66
+ - registration text in swedish translation
67
+
68
+ - show identifier_first node in card header
69
+
70
+ ### ❤️ Thank You
71
+
72
+ - Jonas Hungershausen
73
+
74
+ ## 1.0.0-next.6 (2024-09-18)
75
+
76
+ ### 🩹 Fixes
77
+
78
+ - **intl:** export locales object from package root
79
+
80
+ ### ❤️ Thank You
81
+
82
+ - Jonas Hungershausen
83
+
84
+ ## 1.0.0-next.5 (2024-09-17)
85
+
86
+ ### 🚀 Features
87
+
88
+ - @testing-library/react based tests
89
+
90
+ - **theme:** show resend code button on top of code input
91
+
92
+ ### 🩹 Fixes
93
+
94
+ - **core:** use SDK instead of HTML form submissions
95
+
96
+ - **core:** use empty strings instead of undefined default values
97
+
98
+ - **core:** code form submission precendence
99
+
100
+ - ⚠️ **theme:** scope css classes with .ory-default-theme
101
+
102
+ - **theme:** social sign in button styling
103
+
104
+ - **intl:** use correct abbreveation for swedish locale
105
+
106
+ - **core:** passkey script discovery
107
+
108
+ #### ⚠️ Breaking Changes
109
+
110
+ - ⚠️ **theme:** scope css classes with .ory-default-theme
111
+
112
+ ### ❤️ Thank You
113
+
114
+ - Jonas Hungershausen
115
+ - Miłosz
package/README.md CHANGED
@@ -6,18 +6,171 @@
6
6
 
7
7
  # @ory/elements-react
8
8
 
9
- ---
9
+ <p align="center">
10
+ <a aria-label="NPM Version" href="https://www.npmjs.com/package/@ory/elements-react">
11
+ <img src="https://img.shields.io/npm/v/@ory/elements-react.svg?style=flat-square">
12
+ </a>
13
+ <a aria-label="License" href="https://github.com/ory/elements/blob/main/LICENSE">
14
+ <img src="https://img.shields.io/github/license/ory/elements?style=flat-square">
15
+ </a>
16
+ <a aria-label="Join Ory Slack community!" href="https://slack.ory.sh/">
17
+ <img src="https://img.shields.io/badge/Slack-Join%20the%20community!-4f46e5?style=flat-square&logo=slack&logoColor=eef2ff">
18
+ </a>
19
+ </p>
10
20
 
11
- Ory Elements is a collection of components and functions that help you get an
12
- authentication solution up, running and integrated into your application in no
13
- time.
21
+ Ory Elements is a set of components and functions tailored for easy integration
22
+ of Ory into your React application. It simplifies the process of adding
23
+ authentication and other identity features to your application using the Ory
24
+ Network.
14
25
 
15
- - Documentation: https://ory.sh/docs
26
+ ## Documentation
16
27
 
17
- ## Usage
28
+ Visit https://ory.sh/docs to see the full Ory documentation.
29
+
30
+ ## Getting started
31
+
32
+ **Requirements**
33
+
34
+ - React `>= 18`
35
+ - Node.js `>= 18`
36
+ - **`@ory/client-fetch`** - fetch based version of ory client
18
37
 
19
- Install the package:
38
+ **Installation**
20
39
 
21
40
  ```sh
22
41
  npm install @ory/elements-react
23
42
  ```
43
+
44
+ ## Usage
45
+
46
+ Ory Elements provides components that can aggregate flow objects and display
47
+ user authentication flows based on the data.
48
+
49
+ To feed Ory Elements with flow data you need to use Ory client.
50
+
51
+ ```ts
52
+ export function serverClientFrontend() {
53
+ // For testing purposes we're using Ory tunnel
54
+
55
+ const config = new Configuration({
56
+ headers: {
57
+ Accept: "application/json",
58
+ },
59
+ basePath: "http://localhost:4000",
60
+ })
61
+ return new FrontendApi(config)
62
+ }
63
+ ```
64
+
65
+ ### Ory Network project setup
66
+
67
+ The Ory Identities APIs come with the ability to specify custom UI URLs. To make
68
+ sure, Ory knows about your custom UI, specify the URLs of your application on
69
+ https://console.ory.sh/projects/current/ui.
70
+
71
+ ### Initializing a new flow
72
+
73
+ Initializing a new flow is done by navigating the user's page to the initialize
74
+ flow URL. After creating a new flow object, Ory will return a redirect to the
75
+ flow UI URL and, in some cases, return anti-CSRF cookies.
76
+
77
+ ```ts
78
+ export function init(params: QueryParams, flowType: FlowType) {
79
+ // Take advantage of the fact, that Ory handles the flow creation for us and redirects the user to the default return to automatically if they're logged in already.
80
+ return redirect(
81
+ "http://localhost:4000" +
82
+ "/self-service/" +
83
+ flowType.toString() +
84
+ "/browser?" +
85
+ new URLSearchParams(params).toString(),
86
+ RedirectType.replace,
87
+ )
88
+ }
89
+ ```
90
+
91
+ **FlowType** can be: `login`, `registration`, `recovery`, `verification`,
92
+ `settings` or `error`
93
+
94
+ To access & render the flow, on your flow page, you can use the `flow` query
95
+ parameter, that is included in the redirect. Use it to call the
96
+ [`getLoginFlow()`](https://www.ory.sh/docs/reference/api#tag/frontend/operation/getLoginFlow)
97
+ API.
98
+
99
+ **Full Example**:
100
+
101
+ ````ts
102
+ export async function getOrCreateRegistrationFlow(
103
+ params: QueryParams
104
+ ): Promise<RegistrationFlow> {
105
+ const onRestartFlow = () => init(params, FlowType.Registration);
106
+
107
+ // If flow ID doesn't exist in params simply trigget the init function.
108
+ if (!params.flow) {
109
+ return onRestartFlow();
110
+ }
111
+
112
+ return await serverClientFrontend()
113
+ // Passing the flow ID
114
+ .getRegistrationFlowRaw({ id: flow })
115
+ .then(res => res.value())
116
+ .catch(
117
+ // Ory Elements predefines the handleFlowError function to simplify error handling.
118
+ // You can define what should happen in each of these callbacks
119
+ handleFlowError({
120
+ onValidationError,
121
+ onRestartFlow,
122
+ onRedirect,
123
+ })
124
+ );
125
+ ```
126
+ ````
127
+
128
+ As soon as we have our flow data we can render the `<Registration/>` component
129
+ from `@ory/elements-react` package.
130
+
131
+ ```tsx
132
+ export default async function RegistrationPage({ searchParams }: PageProps) {
133
+ const flow = await getOrCreateRegistrationFlow(searchParams)
134
+
135
+ if (!flow) {
136
+ return <div>Flow not found</div>
137
+ }
138
+
139
+ return (
140
+ <Registration
141
+ flow={flow}
142
+ config={oryConfiguration}
143
+ components={ComponentOverrides}
144
+ />
145
+ )
146
+ }
147
+ ```
148
+
149
+ ### Styling
150
+
151
+ To include the default styles, add the following import to your app. Make sure
152
+ it's included on all pages, that use Ory Elements.
153
+
154
+ ```ts
155
+ import "@ory/elements-react/theme/styles.css"
156
+ ```
157
+
158
+ ### Theming
159
+
160
+ Most styling can be overwritten, by providing your own custom CSS variables:
161
+
162
+ ```css
163
+ :root {
164
+ /* To override the text color of the primary buttons */
165
+ --button-primary-fg-default: #fffeee;
166
+ }
167
+ ```
168
+
169
+ ## Package development
170
+
171
+ To develop and use the package `npm link` is recommended. To run the package in
172
+ watch mode use
173
+
174
+ ```
175
+ npx nx run @ory/elements-react:dev
176
+ ```