@ory/elements-react 1.0.0-next.2 → 1.0.0-next.21

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.
Files changed (69) hide show
  1. package/.vscode/i18n-ally-reviews.yml +3 -0
  2. package/.vscode/settings.json +4 -0
  3. package/CHANGELOG.md +303 -0
  4. package/README.md +179 -7
  5. package/api-report/elements-react-client.api.json +356 -0
  6. package/api-report/elements-react-client.api.md +33 -0
  7. package/api-report/elements-react-theme.api.json +1468 -0
  8. package/api-report/elements-react-theme.api.md +149 -0
  9. package/api-report/elements-react.api.json +3759 -0
  10. package/api-report/elements-react.api.md +442 -0
  11. package/api-report/temp/elements-react-client.api.md +33 -0
  12. package/api-report/temp/elements-react-theme.api.md +149 -0
  13. package/api-report/temp/elements-react.api.md +442 -0
  14. package/config/api-extractor-client.json +463 -0
  15. package/config/api-extractor-core.json +457 -0
  16. package/config/api-extractor-theme.json +463 -0
  17. package/dist/client/config.d.mts +21 -0
  18. package/dist/client/config.d.ts +21 -0
  19. package/dist/client/config.js +77 -0
  20. package/dist/client/config.js.map +1 -0
  21. package/dist/client/config.mjs +51 -0
  22. package/dist/client/config.mjs.map +1 -0
  23. package/dist/client/frontendClient.d.mts +7 -0
  24. package/dist/client/frontendClient.d.ts +7 -0
  25. package/dist/client/frontendClient.js +52 -0
  26. package/dist/client/frontendClient.js.map +1 -0
  27. package/dist/client/frontendClient.mjs +31 -0
  28. package/dist/client/frontendClient.mjs.map +1 -0
  29. package/dist/client/index.d.mts +5 -0
  30. package/dist/client/index.d.ts +5 -0
  31. package/dist/client/index.js +33 -0
  32. package/dist/client/index.js.map +1 -0
  33. package/dist/client/index.mjs +10 -0
  34. package/dist/client/index.mjs.map +1 -0
  35. package/dist/client/session-provider.d.mts +62 -0
  36. package/dist/client/session-provider.d.ts +62 -0
  37. package/dist/client/session-provider.js +96 -0
  38. package/dist/client/session-provider.js.map +1 -0
  39. package/dist/client/session-provider.mjs +71 -0
  40. package/dist/client/session-provider.mjs.map +1 -0
  41. package/dist/client/useSession.d.mts +32 -0
  42. package/dist/client/useSession.d.ts +32 -0
  43. package/dist/client/useSession.js +37 -0
  44. package/dist/client/useSession.js.map +1 -0
  45. package/dist/client/useSession.mjs +13 -0
  46. package/dist/client/useSession.mjs.map +1 -0
  47. package/dist/index.d.mts +441 -1634
  48. package/dist/index.d.ts +441 -1634
  49. package/dist/index.js +2496 -5787
  50. package/dist/index.js.map +1 -1
  51. package/dist/index.mjs +2492 -5756
  52. package/dist/index.mjs.map +1 -1
  53. package/dist/theme/default/index.css +673 -169
  54. package/dist/theme/default/index.css.map +1 -1
  55. package/dist/theme/default/index.d.mts +29 -142
  56. package/dist/theme/default/index.d.ts +29 -142
  57. package/dist/theme/default/index.js +1968 -10130
  58. package/dist/theme/default/index.js.map +1 -1
  59. package/dist/theme/default/index.mjs +2014 -10203
  60. package/dist/theme/default/index.mjs.map +1 -1
  61. package/jest.config.ts +23 -0
  62. package/package.json +34 -9
  63. package/postcss.config.ts +1 -0
  64. package/tailwind.config.ts +21 -12
  65. package/tsconfig.json +15 -3
  66. package/tsconfig.spec.json +20 -0
  67. package/variables-processed.json +385 -187
  68. package/.eslintrc.js +0 -61
  69. package/test-results/.last-run.json +0 -4
@@ -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,303 @@
1
+ ## 1.0.0-next.21 (2025-01-18)
2
+
3
+ This was a version bump only for @ory/elements-react to align it with other projects, there were no code changes.
4
+
5
+ ## 1.0.0-next.20 (2025-01-16)
6
+
7
+ ### 🚀 Features
8
+
9
+ - handle state transition edge cases ([f2e4023](https://github.com/ory/elements/commit/f2e4023))
10
+ - user experience improvements and e2e test coverage ([f68744c](https://github.com/ory/elements/commit/f68744c))
11
+ - do not show two-step selector if only one method exists ([6453673](https://github.com/ory/elements/commit/6453673))
12
+
13
+ ### 🩹 Fixes
14
+
15
+ - better validation for code method ([b0d8e2c](https://github.com/ory/elements/commit/b0d8e2c))
16
+
17
+ ### ❤️ Thank You
18
+
19
+ - aeneasr @aeneasr
20
+
21
+ ## 1.0.0-next.19 (2024-12-31)
22
+
23
+ ### 🩹 Fixes
24
+
25
+ - properly handle form submits in settings flow ([#322](https://github.com/ory/elements/pull/322))
26
+
27
+ ### ❤️ Thank You
28
+
29
+ - Jonas Hungershausen
30
+
31
+ ## 1.0.0-next.18 (2024-12-30)
32
+
33
+ ### 🚀 Features
34
+
35
+ - add page and app router examples ([#307](https://github.com/ory/elements/pull/307))
36
+ - ⚠️ add getServerSession and SessionProvider ([#309](https://github.com/ory/elements/pull/309))
37
+ - add @ory/nextjs package ([#303](https://github.com/ory/elements/pull/303))
38
+
39
+ ### 🩹 Fixes
40
+
41
+ - align font sizes to design & use updated variable names ([#318](https://github.com/ory/elements/pull/318))
42
+ - properly set default value for checkboxes ([#314](https://github.com/ory/elements/pull/314))
43
+ - passkey and webauthn in settings flow ([#317](https://github.com/ory/elements/pull/317))
44
+
45
+ ### ⚠️ Breaking Changes
46
+
47
+ - ⚠️ add getServerSession and SessionProvider ([#309](https://github.com/ory/elements/pull/309))
48
+
49
+ ### ❤️ Thank You
50
+
51
+ - hackerman @aeneasr
52
+ - Jonas Hungershausen
53
+
54
+ ## 1.0.0-next.17 (2024-11-27)
55
+
56
+
57
+ ### 🚀 Features
58
+
59
+ - allow overriding OIDC logos
60
+
61
+ - enable proper account linking flows
62
+
63
+ - **core:** add react-hook form resolver
64
+
65
+
66
+ ### 🩹 Fixes
67
+
68
+ - handle recovery brute force protection
69
+
70
+
71
+ ### ❤️ Thank You
72
+
73
+ - Jonas Hungershausen
74
+
75
+ ## 1.0.0-next.16 (2024-11-26)
76
+
77
+
78
+ ### 🚀 Features
79
+
80
+ - allow overriding of field messages
81
+
82
+ - add test ids to components
83
+
84
+
85
+ ### 🩹 Fixes
86
+
87
+ - use --font-sans CSS variable for font
88
+
89
+ - registration & login flow form states
90
+
91
+ - missing resend button on login & registration
92
+
93
+ - password validation error form state
94
+
95
+ - current identifier button overflowing on long values
96
+
97
+
98
+ ### ❤️ Thank You
99
+
100
+ - Jonas Hungershausen
101
+
102
+ ## 1.0.0-next.15 (2024-11-18)
103
+
104
+
105
+ ### 🩹 Fixes
106
+
107
+ - use --font-sans CSS variable for font
108
+
109
+ - registration & login flow form states
110
+
111
+
112
+ ### ❤️ Thank You
113
+
114
+ - Jonas Hungershausen
115
+
116
+ ## 1.0.0-next.14 (2024-11-08)
117
+
118
+
119
+ ### 🚀 Features
120
+
121
+ - force OIDC account selection on settings
122
+
123
+
124
+ ### 🩹 Fixes
125
+
126
+ - redirect to login if session expired during settings
127
+
128
+
129
+ ### ❤️ Thank You
130
+
131
+ - Jonas Hungershausen
132
+
133
+ ## 1.0.0-next.13 (2024-11-05)
134
+
135
+
136
+ ### 🩹 Fixes
137
+
138
+ - ⚠️ move useSession hook to /client entry point
139
+
140
+ - oidc linking & unlinking form properties
141
+
142
+ - hide two step registration message
143
+
144
+ - implement component merging instead of usign lodash
145
+
146
+ - replace translation merge with custom function
147
+
148
+
149
+ #### ⚠️ Breaking Changes
150
+
151
+ - ⚠️ move useSession hook to /client entry point
152
+
153
+ ### ❤️ Thank You
154
+
155
+ - Jonas Hungershausen
156
+
157
+ ## 1.0.0-next.12 (2024-10-29)
158
+
159
+
160
+ ### 🚀 Features
161
+
162
+ - add elements v1 packages
163
+
164
+ - add useSession hook
165
+
166
+ - add page header component with user menu
167
+
168
+ - support links in checkbox/boolean nodes
169
+
170
+ - add settings flow components
171
+
172
+
173
+ ### 🩹 Fixes
174
+
175
+ - use correct node to detect two step registration
176
+
177
+ - use translations in more missing places
178
+
179
+ - short-circuit code login on two step card
180
+
181
+ - duplicate resend button on recovery & verification
182
+
183
+
184
+ ### ❤️ Thank You
185
+
186
+ - Jonas Hungershausen
187
+ - Miłosz
188
+
189
+ ## 1.0.0-next.11 (2024-10-22)
190
+
191
+ 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.
192
+
193
+
194
+ ### 🚀 Features
195
+
196
+ - add elements v1 packages
197
+
198
+ - add useSession hook
199
+
200
+ ### ❤️ Thank You
201
+
202
+ - Jonas Hungershausen
203
+
204
+ ## 1.0.0-next.10 (2024-10-14)
205
+
206
+
207
+ ### 🩹 Fixes
208
+
209
+ - add missing translations in all places
210
+
211
+
212
+ ### ❤️ Thank You
213
+
214
+ - Jonas Hungershausen
215
+
216
+ ## 1.0.0-next.9 (2024-10-10)
217
+
218
+
219
+ ### 🩹 Fixes
220
+
221
+ - add missing swedish translations
222
+
223
+
224
+ ### ❤️ Thank You
225
+
226
+ - Jonas Hungershausen
227
+
228
+ ## 1.0.0-next.8 (2024-10-07)
229
+
230
+
231
+ ### 🩹 Fixes
232
+
233
+ - ⚠️ remove ory-default-theme class
234
+
235
+ - remove capitalize class from messages
236
+
237
+
238
+ #### ⚠️ Breaking Changes
239
+
240
+ - ⚠️ remove ory-default-theme class
241
+
242
+ ### ❤️ Thank You
243
+
244
+ - Jonas Hungershausen
245
+
246
+ ## 1.0.0-next.7 (2024-09-27)
247
+
248
+ ### 🚀 Features
249
+
250
+ - add two-step login card
251
+
252
+ ### 🩹 Fixes
253
+
254
+ - registration text in swedish translation
255
+
256
+ - show identifier_first node in card header
257
+
258
+ ### ❤️ Thank You
259
+
260
+ - Jonas Hungershausen
261
+
262
+ ## 1.0.0-next.6 (2024-09-18)
263
+
264
+ ### 🩹 Fixes
265
+
266
+ - **intl:** export locales object from package root
267
+
268
+ ### ❤️ Thank You
269
+
270
+ - Jonas Hungershausen
271
+
272
+ ## 1.0.0-next.5 (2024-09-17)
273
+
274
+ ### 🚀 Features
275
+
276
+ - @testing-library/react based tests
277
+
278
+ - **theme:** show resend code button on top of code input
279
+
280
+ ### 🩹 Fixes
281
+
282
+ - **core:** use SDK instead of HTML form submissions
283
+
284
+ - **core:** use empty strings instead of undefined default values
285
+
286
+ - **core:** code form submission precendence
287
+
288
+ - ⚠️ **theme:** scope css classes with .ory-default-theme
289
+
290
+ - **theme:** social sign in button styling
291
+
292
+ - **intl:** use correct abbreveation for swedish locale
293
+
294
+ - **core:** passkey script discovery
295
+
296
+ #### ⚠️ Breaking Changes
297
+
298
+ - ⚠️ **theme:** scope css classes with .ory-default-theme
299
+
300
+ ### ❤️ Thank You
301
+
302
+ - Jonas Hungershausen
303
+ - Miłosz
package/README.md CHANGED
@@ -6,18 +6,190 @@
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
18
31
 
19
- Install the package:
32
+ **Requirements**
33
+
34
+ - React `>= 18`
35
+ - Node.js `>= 18`
36
+ - **`@ory/client-fetch`** - fetch based version of ory client
37
+
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
+ ```
177
+
178
+ ### Testing
179
+
180
+ To run the tests use
181
+
182
+ ```
183
+ nx lint @ory/elements-react
184
+ nx test @ory/elements-react
185
+ ```
186
+
187
+ #### Test selectors
188
+
189
+ To select elements use a `data-testid` selector. Nomenclature mandates `/` as
190
+ separators and a prefix of `ory/`:
191
+
192
+ - `ory/form/` is the prefix for form elements;
193
+ - `ory/screen/` is the prefix for elements on specific screens;
194
+ - `ory/screen/` is the prefix for translatable messages (e.g. validation
195
+ errors).