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

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.
@@ -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,100 @@
1
+ ## 1.0.0-next.10 (2024-10-14)
2
+
3
+
4
+ ### 🩹 Fixes
5
+
6
+ - add missing translations in all places
7
+
8
+
9
+ ### ❤️ Thank You
10
+
11
+ - Jonas Hungershausen
12
+
13
+ ## 1.0.0-next.9 (2024-10-10)
14
+
15
+
16
+ ### 🩹 Fixes
17
+
18
+ - add missing swedish translations
19
+
20
+
21
+ ### ❤️ Thank You
22
+
23
+ - Jonas Hungershausen
24
+
25
+ ## 1.0.0-next.8 (2024-10-07)
26
+
27
+
28
+ ### 🩹 Fixes
29
+
30
+ - ⚠️ remove ory-default-theme class
31
+
32
+ - remove capitalize class from messages
33
+
34
+
35
+ #### ⚠️ Breaking Changes
36
+
37
+ - ⚠️ remove ory-default-theme class
38
+
39
+ ### ❤️ Thank You
40
+
41
+ - Jonas Hungershausen
42
+
43
+ ## 1.0.0-next.7 (2024-09-27)
44
+
45
+ ### 🚀 Features
46
+
47
+ - add two-step login card
48
+
49
+ ### 🩹 Fixes
50
+
51
+ - registration text in swedish translation
52
+
53
+ - show identifier_first node in card header
54
+
55
+ ### ❤️ Thank You
56
+
57
+ - Jonas Hungershausen
58
+
59
+ ## 1.0.0-next.6 (2024-09-18)
60
+
61
+ ### 🩹 Fixes
62
+
63
+ - **intl:** export locales object from package root
64
+
65
+ ### ❤️ Thank You
66
+
67
+ - Jonas Hungershausen
68
+
69
+ ## 1.0.0-next.5 (2024-09-17)
70
+
71
+ ### 🚀 Features
72
+
73
+ - @testing-library/react based tests
74
+
75
+ - **theme:** show resend code button on top of code input
76
+
77
+ ### 🩹 Fixes
78
+
79
+ - **core:** use SDK instead of HTML form submissions
80
+
81
+ - **core:** use empty strings instead of undefined default values
82
+
83
+ - **core:** code form submission precendence
84
+
85
+ - ⚠️ **theme:** scope css classes with .ory-default-theme
86
+
87
+ - **theme:** social sign in button styling
88
+
89
+ - **intl:** use correct abbreveation for swedish locale
90
+
91
+ - **core:** passkey script discovery
92
+
93
+ #### ⚠️ Breaking Changes
94
+
95
+ - ⚠️ **theme:** scope css classes with .ory-default-theme
96
+
97
+ ### ❤️ Thank You
98
+
99
+ - Jonas Hungershausen
100
+ - 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
+ ```