@ory/elements-react 1.0.0-next.17 → 1.0.0-next.19

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 (61) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/api-report/elements-react-client.api.json +144 -16
  3. package/api-report/elements-react-client.api.md +19 -8
  4. package/api-report/elements-react-theme.api.json +47 -0
  5. package/api-report/elements-react-theme.api.md +5 -2
  6. package/api-report/elements-react.api.json +85 -23
  7. package/api-report/elements-react.api.md +37 -16
  8. package/api-report/temp/elements-react-client.api.md +19 -8
  9. package/api-report/temp/elements-react-theme.api.md +5 -2
  10. package/api-report/temp/elements-react.api.md +37 -16
  11. package/dist/client/config.d.mts +21 -0
  12. package/dist/client/config.d.ts +21 -0
  13. package/dist/client/config.js +77 -0
  14. package/dist/client/config.js.map +1 -0
  15. package/dist/client/config.mjs +51 -0
  16. package/dist/client/config.mjs.map +1 -0
  17. package/dist/client/frontendClient.d.mts +3 -1
  18. package/dist/client/frontendClient.d.ts +3 -1
  19. package/dist/client/frontendClient.js +14 -2
  20. package/dist/client/frontendClient.js.map +1 -1
  21. package/dist/client/frontendClient.mjs +14 -2
  22. package/dist/client/frontendClient.mjs.map +1 -1
  23. package/dist/client/index.d.mts +3 -1
  24. package/dist/client/index.d.ts +3 -1
  25. package/dist/client/index.js +4 -0
  26. package/dist/client/index.js.map +1 -1
  27. package/dist/client/index.mjs +5 -0
  28. package/dist/client/index.mjs.map +1 -1
  29. package/dist/client/session-provider.d.mts +62 -0
  30. package/dist/client/session-provider.d.ts +62 -0
  31. package/dist/client/session-provider.js +96 -0
  32. package/dist/client/session-provider.js.map +1 -0
  33. package/dist/client/session-provider.mjs +71 -0
  34. package/dist/client/session-provider.mjs.map +1 -0
  35. package/dist/client/useSession.d.mts +22 -31
  36. package/dist/client/useSession.d.ts +22 -31
  37. package/dist/client/useSession.js +7 -49
  38. package/dist/client/useSession.js.map +1 -1
  39. package/dist/client/useSession.mjs +8 -49
  40. package/dist/client/useSession.mjs.map +1 -1
  41. package/dist/index.d.mts +36 -19
  42. package/dist/index.d.ts +36 -19
  43. package/dist/index.js +583 -402
  44. package/dist/index.js.map +1 -1
  45. package/dist/index.mjs +586 -405
  46. package/dist/index.mjs.map +1 -1
  47. package/dist/theme/default/index.css +393 -259
  48. package/dist/theme/default/index.css.map +1 -1
  49. package/dist/theme/default/index.d.mts +4 -2
  50. package/dist/theme/default/index.d.ts +4 -2
  51. package/dist/theme/default/index.js +728 -588
  52. package/dist/theme/default/index.js.map +1 -1
  53. package/dist/theme/default/index.mjs +665 -526
  54. package/dist/theme/default/index.mjs.map +1 -1
  55. package/jest.config.ts +1 -1
  56. package/package.json +2 -1
  57. package/postcss.config.ts +1 -0
  58. package/tailwind.config.ts +14 -13
  59. package/tsconfig.json +4 -3
  60. package/variables-processed.json +385 -187
  61. package/.eslintrc.js +0 -63
@@ -138,6 +138,13 @@ export type OryCardLogoProps = Record<string, never>;
138
138
  // @public (undocumented)
139
139
  export type OryCardProps = PropsWithChildren;
140
140
 
141
+ // @public (undocumented)
142
+ export type OryCardSettingsSectionProps = PropsWithChildren & {
143
+ action: string;
144
+ method: string;
145
+ onSubmit: FormEventHandler<HTMLFormElement>;
146
+ };
147
+
141
148
  // @public (undocumented)
142
149
  export function OryCardValidationMessages({ ...props }: OryMessageRootProps): react_jsx_runtime.JSX.Element | null;
143
150
 
@@ -189,9 +196,9 @@ export type OryFlowComponents = {
189
196
  Logo: ComponentType<OryCardLogoProps>;
190
197
  Divider: ComponentType<OryCardDividerProps>;
191
198
  AuthMethodListItem: ComponentType<OryCardAuthMethodListItemProps>;
192
- SettingsSection: ComponentType<OryFormSectionProps>;
199
+ SettingsSection: ComponentType<OryCardSettingsSectionProps>;
193
200
  SettingsSectionContent: ComponentType<OryFormSectionContentProps>;
194
- SettingsSectionFooter: ComponentType<OryFormSectionContentProps>;
201
+ SettingsSectionFooter: ComponentType<OryFormSectionFooterProps>;
195
202
  };
196
203
  Form: {
197
204
  Root: ComponentType<OryFormRootProps>;
@@ -256,7 +263,7 @@ export type OryFormRootProps = ComponentPropsWithoutRef<"form"> & {
256
263
  };
257
264
 
258
265
  // @public (undocumented)
259
- export function OryFormSection({ children, nodes }: OryFormSectionProps): react_jsx_runtime.JSX.Element;
266
+ export function OryFormSection({ children, nodes, ...rest }: OryFormSectionProps): react_jsx_runtime.JSX.Element;
260
267
 
261
268
  // @public (undocumented)
262
269
  export type OryFormSectionContentProps = PropsWithChildren<{
@@ -265,10 +272,14 @@ export type OryFormSectionContentProps = PropsWithChildren<{
265
272
  }>;
266
273
 
267
274
  // @public (undocumented)
268
- export type OryFormSectionFooterProps = PropsWithChildren;
275
+ export type OryFormSectionFooterProps = PropsWithChildren<{
276
+ text?: string;
277
+ }>;
269
278
 
279
+ // Warning: (ae-forgotten-export) The symbol "OryFormProps$1" needs to be exported by the entry point index.d.ts
280
+ //
270
281
  // @public (undocumented)
271
- export type OryFormSectionProps = PropsWithChildren<{
282
+ export type OryFormSectionProps = PropsWithChildren<OryFormProps$1 & {
272
283
  nodes?: UiNode[];
273
284
  }>;
274
285
 
@@ -350,8 +361,12 @@ export function OrySettingsCard(): react_jsx_runtime.JSX.Element;
350
361
 
351
362
  // @public (undocumented)
352
363
  export type OrySettingsOidcProps = {
353
- linkButtons: UiNode[];
354
- unlinkButtons: UiNode[];
364
+ linkButtons: (UiNode & {
365
+ onClick: () => void;
366
+ })[];
367
+ unlinkButtons: (UiNode & {
368
+ onClick: () => void;
369
+ })[];
355
370
  };
356
371
 
357
372
  // @public (undocumented)
@@ -359,23 +374,27 @@ export type OrySettingsPasskeyProps = {
359
374
  triggerButton: UiNode & {
360
375
  onClick: () => void;
361
376
  };
362
- removeButtons: UiNode[];
377
+ removeButtons: (UiNode & {
378
+ onClick: () => void;
379
+ })[];
363
380
  };
364
381
 
365
382
  // @public (undocumented)
366
383
  export type OrySettingsRecoveryCodesProps = {
367
384
  codes: string[];
368
- regnerateButton?: UiNode;
369
- revealButton?: UiNode;
385
+ regnerateButton: UiNode | undefined;
386
+ revealButton: UiNode | undefined;
387
+ onRegenerate: () => void;
388
+ onReveal: () => void;
370
389
  };
371
390
 
372
391
  // @public (undocumented)
373
392
  export type OrySettingsTotpProps = {
374
- totpImage: UiNode;
375
- totpSecret: UiNode;
376
- totpInput: UiNode;
377
- } | {
378
- totpUnlink: UiNode;
393
+ totpImage: UiNode | undefined;
394
+ totpSecret: UiNode | undefined;
395
+ totpInput: UiNode | undefined;
396
+ totpUnlink: UiNode | undefined;
397
+ onUnlink: () => void;
379
398
  };
380
399
 
381
400
  // @public (undocumented)
@@ -384,7 +403,9 @@ export type OrySettingsWebauthnProps = {
384
403
  triggerButton: UiNode & {
385
404
  onClick: () => void;
386
405
  };
387
- removeButtons: UiNode[];
406
+ removeButtons: (UiNode & {
407
+ onClick: () => void;
408
+ })[];
388
409
  };
389
410
 
390
411
  // @public (undocumented)
@@ -4,19 +4,30 @@
4
4
 
5
5
  ```ts
6
6
 
7
+ import * as react_jsx_runtime from 'react/jsx-runtime';
7
8
  import { Session } from '@ory/client-fetch';
8
9
 
9
- // @public
10
- export const useSession: (config?: {
11
- sdk: {
12
- url: string;
13
- };
14
- }) => {
15
- session: Session | undefined;
16
- error: string | undefined;
10
+ // @public (undocumented)
11
+ export type SessionContextData = {
17
12
  isLoading: boolean;
13
+ initialized: boolean;
14
+ session: Session | null;
15
+ error: Error | undefined;
16
+ refetch: () => Promise<void>;
18
17
  };
19
18
 
19
+ // @public
20
+ export function SessionProvider({ session: initialSession, children, baseUrl, }: SessionProviderProps): react_jsx_runtime.JSX.Element;
21
+
22
+ // @public (undocumented)
23
+ export type SessionProviderProps = {
24
+ session?: Session | null;
25
+ baseUrl?: string;
26
+ } & React.PropsWithChildren;
27
+
28
+ // @public
29
+ export function useSession(): SessionContextData;
30
+
20
31
  // (No @packageDocumentation comment for this package)
21
32
 
22
33
  ```
@@ -56,6 +56,9 @@ export function DefaultCardFooter(): react_jsx_runtime.JSX.Element | null;
56
56
  // @public (undocumented)
57
57
  export function DefaultCardHeader(): react_jsx_runtime.JSX.Element;
58
58
 
59
+ // @public (undocumented)
60
+ export function DefaultCardLayout({ children }: PropsWithChildren): react_jsx_runtime.JSX.Element;
61
+
59
62
  // @public (undocumented)
60
63
  export function DefaultCardLogo(): react_jsx_runtime.JSX.Element;
61
64
 
@@ -138,8 +141,8 @@ export type VerificationFlowContextProps = {
138
141
 
139
142
  // Warnings were encountered during analysis:
140
143
  //
141
- // dist/theme/default/index.d.ts:36:5 - (ae-forgotten-export) The symbol "OryFlowComponentOverrides" needs to be exported by the entry point index.d.ts
142
- // dist/theme/default/index.d.ts:37:5 - (ae-forgotten-export) The symbol "OryClientConfiguration" needs to be exported by the entry point index.d.ts
144
+ // dist/theme/default/index.d.ts:38:5 - (ae-forgotten-export) The symbol "OryFlowComponentOverrides" needs to be exported by the entry point index.d.ts
145
+ // dist/theme/default/index.d.ts:39:5 - (ae-forgotten-export) The symbol "OryClientConfiguration" needs to be exported by the entry point index.d.ts
143
146
 
144
147
  // (No @packageDocumentation comment for this package)
145
148
 
@@ -138,6 +138,13 @@ export type OryCardLogoProps = Record<string, never>;
138
138
  // @public (undocumented)
139
139
  export type OryCardProps = PropsWithChildren;
140
140
 
141
+ // @public (undocumented)
142
+ export type OryCardSettingsSectionProps = PropsWithChildren & {
143
+ action: string;
144
+ method: string;
145
+ onSubmit: FormEventHandler<HTMLFormElement>;
146
+ };
147
+
141
148
  // @public (undocumented)
142
149
  export function OryCardValidationMessages({ ...props }: OryMessageRootProps): react_jsx_runtime.JSX.Element | null;
143
150
 
@@ -189,9 +196,9 @@ export type OryFlowComponents = {
189
196
  Logo: ComponentType<OryCardLogoProps>;
190
197
  Divider: ComponentType<OryCardDividerProps>;
191
198
  AuthMethodListItem: ComponentType<OryCardAuthMethodListItemProps>;
192
- SettingsSection: ComponentType<OryFormSectionProps>;
199
+ SettingsSection: ComponentType<OryCardSettingsSectionProps>;
193
200
  SettingsSectionContent: ComponentType<OryFormSectionContentProps>;
194
- SettingsSectionFooter: ComponentType<OryFormSectionContentProps>;
201
+ SettingsSectionFooter: ComponentType<OryFormSectionFooterProps>;
195
202
  };
196
203
  Form: {
197
204
  Root: ComponentType<OryFormRootProps>;
@@ -256,7 +263,7 @@ export type OryFormRootProps = ComponentPropsWithoutRef<"form"> & {
256
263
  };
257
264
 
258
265
  // @public (undocumented)
259
- export function OryFormSection({ children, nodes }: OryFormSectionProps): react_jsx_runtime.JSX.Element;
266
+ export function OryFormSection({ children, nodes, ...rest }: OryFormSectionProps): react_jsx_runtime.JSX.Element;
260
267
 
261
268
  // @public (undocumented)
262
269
  export type OryFormSectionContentProps = PropsWithChildren<{
@@ -265,10 +272,14 @@ export type OryFormSectionContentProps = PropsWithChildren<{
265
272
  }>;
266
273
 
267
274
  // @public (undocumented)
268
- export type OryFormSectionFooterProps = PropsWithChildren;
275
+ export type OryFormSectionFooterProps = PropsWithChildren<{
276
+ text?: string;
277
+ }>;
269
278
 
279
+ // Warning: (ae-forgotten-export) The symbol "OryFormProps$1" needs to be exported by the entry point index.d.ts
280
+ //
270
281
  // @public (undocumented)
271
- export type OryFormSectionProps = PropsWithChildren<{
282
+ export type OryFormSectionProps = PropsWithChildren<OryFormProps$1 & {
272
283
  nodes?: UiNode[];
273
284
  }>;
274
285
 
@@ -350,8 +361,12 @@ export function OrySettingsCard(): react_jsx_runtime.JSX.Element;
350
361
 
351
362
  // @public (undocumented)
352
363
  export type OrySettingsOidcProps = {
353
- linkButtons: UiNode[];
354
- unlinkButtons: UiNode[];
364
+ linkButtons: (UiNode & {
365
+ onClick: () => void;
366
+ })[];
367
+ unlinkButtons: (UiNode & {
368
+ onClick: () => void;
369
+ })[];
355
370
  };
356
371
 
357
372
  // @public (undocumented)
@@ -359,23 +374,27 @@ export type OrySettingsPasskeyProps = {
359
374
  triggerButton: UiNode & {
360
375
  onClick: () => void;
361
376
  };
362
- removeButtons: UiNode[];
377
+ removeButtons: (UiNode & {
378
+ onClick: () => void;
379
+ })[];
363
380
  };
364
381
 
365
382
  // @public (undocumented)
366
383
  export type OrySettingsRecoveryCodesProps = {
367
384
  codes: string[];
368
- regnerateButton?: UiNode;
369
- revealButton?: UiNode;
385
+ regnerateButton: UiNode | undefined;
386
+ revealButton: UiNode | undefined;
387
+ onRegenerate: () => void;
388
+ onReveal: () => void;
370
389
  };
371
390
 
372
391
  // @public (undocumented)
373
392
  export type OrySettingsTotpProps = {
374
- totpImage: UiNode;
375
- totpSecret: UiNode;
376
- totpInput: UiNode;
377
- } | {
378
- totpUnlink: UiNode;
393
+ totpImage: UiNode | undefined;
394
+ totpSecret: UiNode | undefined;
395
+ totpInput: UiNode | undefined;
396
+ totpUnlink: UiNode | undefined;
397
+ onUnlink: () => void;
379
398
  };
380
399
 
381
400
  // @public (undocumented)
@@ -384,7 +403,9 @@ export type OrySettingsWebauthnProps = {
384
403
  triggerButton: UiNode & {
385
404
  onClick: () => void;
386
405
  };
387
- removeButtons: UiNode[];
406
+ removeButtons: (UiNode & {
407
+ onClick: () => void;
408
+ })[];
388
409
  };
389
410
 
390
411
  // @public (undocumented)
@@ -0,0 +1,21 @@
1
+ /**
2
+ * This function returns the base URL of the Ory SDK as set by environment variables `NEXT_PUBLIC_ORY_SDK_URL` or `ORY_SDK_URL`.
3
+ */
4
+ declare function orySdkUrl(): string;
5
+ /**
6
+ * This function returns whether the current environment is a production environment.
7
+ */
8
+ declare function isProduction(): boolean;
9
+ /**
10
+ * This function returns the Ory SDK URL. If the environment is not production, it tries to guess the SDK URL based on the environment variables, assuming
11
+ * that Ory APIs are proxied through the same domain as the application.
12
+ *
13
+ * Currently, this is only tested for Vercel deployments.
14
+ *
15
+ * @param options - Options for guessing the SDK URL.
16
+ */
17
+ declare function guessPotentiallyProxiedOrySdkUrl(options?: {
18
+ knownProxiedUrl?: string;
19
+ }): string;
20
+
21
+ export { guessPotentiallyProxiedOrySdkUrl, isProduction, orySdkUrl };
@@ -0,0 +1,21 @@
1
+ /**
2
+ * This function returns the base URL of the Ory SDK as set by environment variables `NEXT_PUBLIC_ORY_SDK_URL` or `ORY_SDK_URL`.
3
+ */
4
+ declare function orySdkUrl(): string;
5
+ /**
6
+ * This function returns whether the current environment is a production environment.
7
+ */
8
+ declare function isProduction(): boolean;
9
+ /**
10
+ * This function returns the Ory SDK URL. If the environment is not production, it tries to guess the SDK URL based on the environment variables, assuming
11
+ * that Ory APIs are proxied through the same domain as the application.
12
+ *
13
+ * Currently, this is only tested for Vercel deployments.
14
+ *
15
+ * @param options - Options for guessing the SDK URL.
16
+ */
17
+ declare function guessPotentiallyProxiedOrySdkUrl(options?: {
18
+ knownProxiedUrl?: string;
19
+ }): string;
20
+
21
+ export { guessPotentiallyProxiedOrySdkUrl, isProduction, orySdkUrl };
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var config_exports = {};
20
+ __export(config_exports, {
21
+ guessPotentiallyProxiedOrySdkUrl: () => guessPotentiallyProxiedOrySdkUrl,
22
+ isProduction: () => isProduction,
23
+ orySdkUrl: () => orySdkUrl
24
+ });
25
+ module.exports = __toCommonJS(config_exports);
26
+ function orySdkUrl() {
27
+ let baseUrl;
28
+ if (process.env.NEXT_PUBLIC_ORY_SDK_URL) {
29
+ baseUrl = process.env.NEXT_PUBLIC_ORY_SDK_URL;
30
+ }
31
+ if (process.env.ORY_SDK_URL) {
32
+ baseUrl = process.env._ORY_SDK_URL;
33
+ }
34
+ if (!baseUrl) {
35
+ throw new Error(
36
+ "You need to set environment variable `NEXT_PUBLIC_ORY_SDK_URL` or if you don't use Next.js `ORY_SDK_URL` to your Ory Network SDK URL."
37
+ );
38
+ }
39
+ return baseUrl.replace(/\/$/, "");
40
+ }
41
+ function isProduction() {
42
+ var _a, _b;
43
+ return ["production", "prod"].indexOf(
44
+ (_b = (_a = process.env.VERCEL_ENV) != null ? _a : process.env.NODE_ENV) != null ? _b : ""
45
+ ) > -1;
46
+ }
47
+ function guessPotentiallyProxiedOrySdkUrl(options) {
48
+ if (isProduction()) {
49
+ return orySdkUrl();
50
+ }
51
+ if (process.env.VERCEL_ENV) {
52
+ if (!isProduction() && process.env.VERCEL_URL) {
53
+ return `https://${process.env.VERCEL_URL}`.replace(/\/$/, "");
54
+ }
55
+ if (process.env.__NEXT_PRIVATE_ORIGIN) {
56
+ return process.env.__NEXT_PRIVATE_ORIGIN.replace(/\/$/, "");
57
+ }
58
+ }
59
+ if (typeof window !== "undefined") {
60
+ return window.location.origin;
61
+ }
62
+ if (options == null ? void 0 : options.knownProxiedUrl) {
63
+ return options.knownProxiedUrl;
64
+ }
65
+ const final = orySdkUrl();
66
+ console.warn(
67
+ `Unable to determine a suitable SDK URL for setting up the Next.js integration of Ory Elements. Will proceed using default Ory SDK URL "${final}". This is likely not what you want for local development and your authentication and login may not work.`
68
+ );
69
+ return final;
70
+ }
71
+ // Annotate the CommonJS export names for ESM import in node:
72
+ 0 && (module.exports = {
73
+ guessPotentiallyProxiedOrySdkUrl,
74
+ isProduction,
75
+ orySdkUrl
76
+ });
77
+ //# sourceMappingURL=config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/config.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This function returns the base URL of the Ory SDK as set by environment variables `NEXT_PUBLIC_ORY_SDK_URL` or `ORY_SDK_URL`.\n */\nexport function orySdkUrl() {\n let baseUrl\n\n if (process.env.NEXT_PUBLIC_ORY_SDK_URL) {\n baseUrl = process.env.NEXT_PUBLIC_ORY_SDK_URL\n }\n\n if (process.env.ORY_SDK_URL) {\n baseUrl = process.env._ORY_SDK_URL\n }\n\n if (!baseUrl) {\n throw new Error(\n \"You need to set environment variable `NEXT_PUBLIC_ORY_SDK_URL` or if you don't use Next.js `ORY_SDK_URL` to your Ory Network SDK URL.\",\n )\n }\n\n return baseUrl.replace(/\\/$/, \"\")\n}\n\n/**\n * This function returns whether the current environment is a production environment.\n */\nexport function isProduction() {\n return (\n [\"production\", \"prod\"].indexOf(\n process.env.VERCEL_ENV ?? process.env.NODE_ENV ?? \"\",\n ) > -1\n )\n}\n\n/**\n * This function returns the Ory SDK URL. If the environment is not production, it tries to guess the SDK URL based on the environment variables, assuming\n * that Ory APIs are proxied through the same domain as the application.\n *\n * Currently, this is only tested for Vercel deployments.\n *\n * @param options - Options for guessing the SDK URL.\n */\nexport function guessPotentiallyProxiedOrySdkUrl(options?: {\n knownProxiedUrl?: string\n}) {\n if (isProduction()) {\n // In production, we use the production custom domain\n return orySdkUrl()\n }\n\n if (process.env.VERCEL_ENV) {\n // We are in vercel\n\n // The domain name of the generated deployment URL. Example: *.vercel.app. The value does not include the protocol scheme https://.\n //\n // This is only available for preview deployments on Vercel.\n if (!isProduction() && process.env.VERCEL_URL) {\n return `https://${process.env.VERCEL_URL}`.replace(/\\/$/, \"\")\n }\n\n // This is sometimes set by the render server.\n if (process.env.__NEXT_PRIVATE_ORIGIN) {\n return process.env.__NEXT_PRIVATE_ORIGIN.replace(/\\/$/, \"\")\n }\n }\n\n // Unable to figure out the SDK URL. Either because we are not using Vercel or because we are on a local machine.\n // Let's try to use the window location.\n if (typeof window !== \"undefined\") {\n return window.location.origin\n }\n\n if (options?.knownProxiedUrl) {\n return options.knownProxiedUrl\n }\n\n // We tried everything. Let's use the SDK URL.\n const final = orySdkUrl()\n console.warn(\n `Unable to determine a suitable SDK URL for setting up the Next.js integration of Ory Elements. Will proceed using default Ory SDK URL \"${final}\". This is likely not what you want for local development and your authentication and login may not work.`,\n )\n\n return final\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAMO,SAAS,YAAY;AAC1B,MAAI;AAEJ,MAAI,QAAQ,IAAI,yBAAyB;AACvC,cAAU,QAAQ,IAAI;AAAA,EACxB;AAEA,MAAI,QAAQ,IAAI,aAAa;AAC3B,cAAU,QAAQ,IAAI;AAAA,EACxB;AAEA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO,QAAQ,QAAQ,OAAO,EAAE;AAClC;AAKO,SAAS,eAAe;AA7B/B;AA8BE,SACE,CAAC,cAAc,MAAM,EAAE;AAAA,KACrB,mBAAQ,IAAI,eAAZ,YAA0B,QAAQ,IAAI,aAAtC,YAAkD;AAAA,EACpD,IAAI;AAER;AAUO,SAAS,iCAAiC,SAE9C;AACD,MAAI,aAAa,GAAG;AAElB,WAAO,UAAU;AAAA,EACnB;AAEA,MAAI,QAAQ,IAAI,YAAY;AAM1B,QAAI,CAAC,aAAa,KAAK,QAAQ,IAAI,YAAY;AAC7C,aAAO,WAAW,QAAQ,IAAI,UAAU,GAAG,QAAQ,OAAO,EAAE;AAAA,IAC9D;AAGA,QAAI,QAAQ,IAAI,uBAAuB;AACrC,aAAO,QAAQ,IAAI,sBAAsB,QAAQ,OAAO,EAAE;AAAA,IAC5D;AAAA,EACF;AAIA,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO,OAAO,SAAS;AAAA,EACzB;AAEA,MAAI,mCAAS,iBAAiB;AAC5B,WAAO,QAAQ;AAAA,EACjB;AAGA,QAAM,QAAQ,UAAU;AACxB,UAAQ;AAAA,IACN,0IAA0I,KAAK;AAAA,EACjJ;AAEA,SAAO;AACT;","names":[]}
@@ -0,0 +1,51 @@
1
+ function orySdkUrl() {
2
+ let baseUrl;
3
+ if (process.env.NEXT_PUBLIC_ORY_SDK_URL) {
4
+ baseUrl = process.env.NEXT_PUBLIC_ORY_SDK_URL;
5
+ }
6
+ if (process.env.ORY_SDK_URL) {
7
+ baseUrl = process.env._ORY_SDK_URL;
8
+ }
9
+ if (!baseUrl) {
10
+ throw new Error(
11
+ "You need to set environment variable `NEXT_PUBLIC_ORY_SDK_URL` or if you don't use Next.js `ORY_SDK_URL` to your Ory Network SDK URL."
12
+ );
13
+ }
14
+ return baseUrl.replace(/\/$/, "");
15
+ }
16
+ function isProduction() {
17
+ var _a, _b;
18
+ return ["production", "prod"].indexOf(
19
+ (_b = (_a = process.env.VERCEL_ENV) != null ? _a : process.env.NODE_ENV) != null ? _b : ""
20
+ ) > -1;
21
+ }
22
+ function guessPotentiallyProxiedOrySdkUrl(options) {
23
+ if (isProduction()) {
24
+ return orySdkUrl();
25
+ }
26
+ if (process.env.VERCEL_ENV) {
27
+ if (!isProduction() && process.env.VERCEL_URL) {
28
+ return `https://${process.env.VERCEL_URL}`.replace(/\/$/, "");
29
+ }
30
+ if (process.env.__NEXT_PRIVATE_ORIGIN) {
31
+ return process.env.__NEXT_PRIVATE_ORIGIN.replace(/\/$/, "");
32
+ }
33
+ }
34
+ if (typeof window !== "undefined") {
35
+ return window.location.origin;
36
+ }
37
+ if (options == null ? void 0 : options.knownProxiedUrl) {
38
+ return options.knownProxiedUrl;
39
+ }
40
+ const final = orySdkUrl();
41
+ console.warn(
42
+ `Unable to determine a suitable SDK URL for setting up the Next.js integration of Ory Elements. Will proceed using default Ory SDK URL "${final}". This is likely not what you want for local development and your authentication and login may not work.`
43
+ );
44
+ return final;
45
+ }
46
+ export {
47
+ guessPotentiallyProxiedOrySdkUrl,
48
+ isProduction,
49
+ orySdkUrl
50
+ };
51
+ //# sourceMappingURL=config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/client/config.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * This function returns the base URL of the Ory SDK as set by environment variables `NEXT_PUBLIC_ORY_SDK_URL` or `ORY_SDK_URL`.\n */\nexport function orySdkUrl() {\n let baseUrl\n\n if (process.env.NEXT_PUBLIC_ORY_SDK_URL) {\n baseUrl = process.env.NEXT_PUBLIC_ORY_SDK_URL\n }\n\n if (process.env.ORY_SDK_URL) {\n baseUrl = process.env._ORY_SDK_URL\n }\n\n if (!baseUrl) {\n throw new Error(\n \"You need to set environment variable `NEXT_PUBLIC_ORY_SDK_URL` or if you don't use Next.js `ORY_SDK_URL` to your Ory Network SDK URL.\",\n )\n }\n\n return baseUrl.replace(/\\/$/, \"\")\n}\n\n/**\n * This function returns whether the current environment is a production environment.\n */\nexport function isProduction() {\n return (\n [\"production\", \"prod\"].indexOf(\n process.env.VERCEL_ENV ?? process.env.NODE_ENV ?? \"\",\n ) > -1\n )\n}\n\n/**\n * This function returns the Ory SDK URL. If the environment is not production, it tries to guess the SDK URL based on the environment variables, assuming\n * that Ory APIs are proxied through the same domain as the application.\n *\n * Currently, this is only tested for Vercel deployments.\n *\n * @param options - Options for guessing the SDK URL.\n */\nexport function guessPotentiallyProxiedOrySdkUrl(options?: {\n knownProxiedUrl?: string\n}) {\n if (isProduction()) {\n // In production, we use the production custom domain\n return orySdkUrl()\n }\n\n if (process.env.VERCEL_ENV) {\n // We are in vercel\n\n // The domain name of the generated deployment URL. Example: *.vercel.app. The value does not include the protocol scheme https://.\n //\n // This is only available for preview deployments on Vercel.\n if (!isProduction() && process.env.VERCEL_URL) {\n return `https://${process.env.VERCEL_URL}`.replace(/\\/$/, \"\")\n }\n\n // This is sometimes set by the render server.\n if (process.env.__NEXT_PRIVATE_ORIGIN) {\n return process.env.__NEXT_PRIVATE_ORIGIN.replace(/\\/$/, \"\")\n }\n }\n\n // Unable to figure out the SDK URL. Either because we are not using Vercel or because we are on a local machine.\n // Let's try to use the window location.\n if (typeof window !== \"undefined\") {\n return window.location.origin\n }\n\n if (options?.knownProxiedUrl) {\n return options.knownProxiedUrl\n }\n\n // We tried everything. Let's use the SDK URL.\n const final = orySdkUrl()\n console.warn(\n `Unable to determine a suitable SDK URL for setting up the Next.js integration of Ory Elements. Will proceed using default Ory SDK URL \"${final}\". This is likely not what you want for local development and your authentication and login may not work.`,\n )\n\n return final\n}\n"],"mappings":"AAMO,SAAS,YAAY;AAC1B,MAAI;AAEJ,MAAI,QAAQ,IAAI,yBAAyB;AACvC,cAAU,QAAQ,IAAI;AAAA,EACxB;AAEA,MAAI,QAAQ,IAAI,aAAa;AAC3B,cAAU,QAAQ,IAAI;AAAA,EACxB;AAEA,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO,QAAQ,QAAQ,OAAO,EAAE;AAClC;AAKO,SAAS,eAAe;AA7B/B;AA8BE,SACE,CAAC,cAAc,MAAM,EAAE;AAAA,KACrB,mBAAQ,IAAI,eAAZ,YAA0B,QAAQ,IAAI,aAAtC,YAAkD;AAAA,EACpD,IAAI;AAER;AAUO,SAAS,iCAAiC,SAE9C;AACD,MAAI,aAAa,GAAG;AAElB,WAAO,UAAU;AAAA,EACnB;AAEA,MAAI,QAAQ,IAAI,YAAY;AAM1B,QAAI,CAAC,aAAa,KAAK,QAAQ,IAAI,YAAY;AAC7C,aAAO,WAAW,QAAQ,IAAI,UAAU,GAAG,QAAQ,OAAO,EAAE;AAAA,IAC9D;AAGA,QAAI,QAAQ,IAAI,uBAAuB;AACrC,aAAO,QAAQ,IAAI,sBAAsB,QAAQ,OAAO,EAAE;AAAA,IAC5D;AAAA,EACF;AAIA,MAAI,OAAO,WAAW,aAAa;AACjC,WAAO,OAAO,SAAS;AAAA,EACzB;AAEA,MAAI,mCAAS,iBAAiB;AAC5B,WAAO,QAAQ;AAAA,EACjB;AAGA,QAAM,QAAQ,UAAU;AACxB,UAAQ;AAAA,IACN,0IAA0I,KAAK;AAAA,EACjJ;AAEA,SAAO;AACT;","names":[]}
@@ -1,5 +1,7 @@
1
1
  import { ConfigurationParameters, FrontendApi } from '@ory/client-fetch';
2
2
 
3
- declare function frontendClient(sdkUrl: string, opts?: Partial<ConfigurationParameters>): FrontendApi;
3
+ declare function frontendClient({ forceBaseUrl, ...opts }?: Partial<ConfigurationParameters & {
4
+ forceBaseUrl?: string;
5
+ }>): FrontendApi;
4
6
 
5
7
  export { frontendClient };
@@ -1,5 +1,7 @@
1
1
  import { ConfigurationParameters, FrontendApi } from '@ory/client-fetch';
2
2
 
3
- declare function frontendClient(sdkUrl: string, opts?: Partial<ConfigurationParameters>): FrontendApi;
3
+ declare function frontendClient({ forceBaseUrl, ...opts }?: Partial<ConfigurationParameters & {
4
+ forceBaseUrl?: string;
5
+ }>): FrontendApi;
4
6
 
5
7
  export { frontendClient };
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ "use client";
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -22,10 +23,21 @@ __export(frontendClient_exports, {
22
23
  });
23
24
  module.exports = __toCommonJS(frontendClient_exports);
24
25
  var import_client_fetch = require("@ory/client-fetch");
25
- function frontendClient(sdkUrl, opts = {}) {
26
+ var import_config = require("./config");
27
+ function frontendClient({
28
+ forceBaseUrl,
29
+ ...opts
30
+ } = {
31
+ credentials: "include"
32
+ }) {
33
+ var _a;
34
+ const basePath = forceBaseUrl != null ? forceBaseUrl : (0, import_config.guessPotentiallyProxiedOrySdkUrl)({
35
+ knownProxiedUrl: window.location.origin
36
+ });
26
37
  const config = new import_client_fetch.Configuration({
27
38
  ...opts,
28
- basePath: sdkUrl,
39
+ basePath: basePath == null ? void 0 : basePath.replace(/\/$/, ""),
40
+ credentials: (_a = opts.credentials) != null ? _a : "include",
29
41
  headers: {
30
42
  Accept: "application/json",
31
43
  ...opts.headers
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/frontendClient.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n Configuration,\n ConfigurationParameters,\n FrontendApi,\n} from \"@ory/client-fetch\"\n\nexport function frontendClient(\n sdkUrl: string,\n opts: Partial<ConfigurationParameters> = {},\n) {\n const config = new Configuration({\n ...opts,\n basePath: sdkUrl,\n headers: {\n Accept: \"application/json\",\n ...opts.headers,\n },\n })\n return new FrontendApi(config)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAIO;AAEA,SAAS,eACd,QACA,OAAyC,CAAC,GAC1C;AACA,QAAM,SAAS,IAAI,kCAAc;AAAA,IAC/B,GAAG;AAAA,IACH,UAAU;AAAA,IACV,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,GAAG,KAAK;AAAA,IACV;AAAA,EACF,CAAC;AACD,SAAO,IAAI,gCAAY,MAAM;AAC/B;","names":[]}
1
+ {"version":3,"sources":["../../src/client/frontendClient.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\"use client\"\nimport {\n Configuration,\n ConfigurationParameters,\n FrontendApi,\n} from \"@ory/client-fetch\"\nimport { guessPotentiallyProxiedOrySdkUrl } from \"./config\"\n\nexport function frontendClient(\n {\n forceBaseUrl,\n ...opts\n }: Partial<ConfigurationParameters & { forceBaseUrl?: string }> = {\n credentials: \"include\",\n },\n) {\n const basePath =\n forceBaseUrl ??\n guessPotentiallyProxiedOrySdkUrl({\n knownProxiedUrl: window.location.origin,\n })\n\n const config = new Configuration({\n ...opts,\n basePath: basePath?.replace(/\\/$/, \"\"),\n credentials: opts.credentials ?? \"include\",\n headers: {\n Accept: \"application/json\",\n ...opts.headers,\n },\n })\n return new FrontendApi(config)\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,0BAIO;AACP,oBAAiD;AAE1C,SAAS,eACd;AAAA,EACE;AAAA,EACA,GAAG;AACL,IAAkE;AAAA,EAChE,aAAa;AACf,GACA;AAjBF;AAkBE,QAAM,WACJ,0CACA,gDAAiC;AAAA,IAC/B,iBAAiB,OAAO,SAAS;AAAA,EACnC,CAAC;AAEH,QAAM,SAAS,IAAI,kCAAc;AAAA,IAC/B,GAAG;AAAA,IACH,UAAU,qCAAU,QAAQ,OAAO;AAAA,IACnC,cAAa,UAAK,gBAAL,YAAoB;AAAA,IACjC,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,GAAG,KAAK;AAAA,IACV;AAAA,EACF,CAAC;AACD,SAAO,IAAI,gCAAY,MAAM;AAC/B;","names":[]}
@@ -1,11 +1,23 @@
1
+ "use client";
1
2
  import {
2
3
  Configuration,
3
4
  FrontendApi
4
5
  } from "@ory/client-fetch";
5
- function frontendClient(sdkUrl, opts = {}) {
6
+ import { guessPotentiallyProxiedOrySdkUrl } from "./config";
7
+ function frontendClient({
8
+ forceBaseUrl,
9
+ ...opts
10
+ } = {
11
+ credentials: "include"
12
+ }) {
13
+ var _a;
14
+ const basePath = forceBaseUrl != null ? forceBaseUrl : guessPotentiallyProxiedOrySdkUrl({
15
+ knownProxiedUrl: window.location.origin
16
+ });
6
17
  const config = new Configuration({
7
18
  ...opts,
8
- basePath: sdkUrl,
19
+ basePath: basePath == null ? void 0 : basePath.replace(/\/$/, ""),
20
+ credentials: (_a = opts.credentials) != null ? _a : "include",
9
21
  headers: {
10
22
  Accept: "application/json",
11
23
  ...opts.headers
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/frontendClient.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n Configuration,\n ConfigurationParameters,\n FrontendApi,\n} from \"@ory/client-fetch\"\n\nexport function frontendClient(\n sdkUrl: string,\n opts: Partial<ConfigurationParameters> = {},\n) {\n const config = new Configuration({\n ...opts,\n basePath: sdkUrl,\n headers: {\n Accept: \"application/json\",\n ...opts.headers,\n },\n })\n return new FrontendApi(config)\n}\n"],"mappings":"AAGA;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AAEA,SAAS,eACd,QACA,OAAyC,CAAC,GAC1C;AACA,QAAM,SAAS,IAAI,cAAc;AAAA,IAC/B,GAAG;AAAA,IACH,UAAU;AAAA,IACV,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,GAAG,KAAK;AAAA,IACV;AAAA,EACF,CAAC;AACD,SAAO,IAAI,YAAY,MAAM;AAC/B;","names":[]}
1
+ {"version":3,"sources":["../../src/client/frontendClient.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\"use client\"\nimport {\n Configuration,\n ConfigurationParameters,\n FrontendApi,\n} from \"@ory/client-fetch\"\nimport { guessPotentiallyProxiedOrySdkUrl } from \"./config\"\n\nexport function frontendClient(\n {\n forceBaseUrl,\n ...opts\n }: Partial<ConfigurationParameters & { forceBaseUrl?: string }> = {\n credentials: \"include\",\n },\n) {\n const basePath =\n forceBaseUrl ??\n guessPotentiallyProxiedOrySdkUrl({\n knownProxiedUrl: window.location.origin,\n })\n\n const config = new Configuration({\n ...opts,\n basePath: basePath?.replace(/\\/$/, \"\"),\n credentials: opts.credentials ?? \"include\",\n headers: {\n Accept: \"application/json\",\n ...opts.headers,\n },\n })\n return new FrontendApi(config)\n}\n"],"mappings":";AAGA;AAAA,EACE;AAAA,EAEA;AAAA,OACK;AACP,SAAS,wCAAwC;AAE1C,SAAS,eACd;AAAA,EACE;AAAA,EACA,GAAG;AACL,IAAkE;AAAA,EAChE,aAAa;AACf,GACA;AAjBF;AAkBE,QAAM,WACJ,sCACA,iCAAiC;AAAA,IAC/B,iBAAiB,OAAO,SAAS;AAAA,EACnC,CAAC;AAEH,QAAM,SAAS,IAAI,cAAc;AAAA,IAC/B,GAAG;AAAA,IACH,UAAU,qCAAU,QAAQ,OAAO;AAAA,IACnC,cAAa,UAAK,gBAAL,YAAoB;AAAA,IACjC,SAAS;AAAA,MACP,QAAQ;AAAA,MACR,GAAG,KAAK;AAAA,IACV;AAAA,EACF,CAAC;AACD,SAAO,IAAI,YAAY,MAAM;AAC/B;","names":[]}
@@ -1,3 +1,5 @@
1
+ export { SessionContextData, SessionProvider, SessionProviderProps } from './session-provider.mjs';
1
2
  export { useSession } from './useSession.mjs';
2
- import 'zustand';
3
+ import 'react/jsx-runtime';
4
+ import 'react';
3
5
  import '@ory/client-fetch';
@@ -1,3 +1,5 @@
1
+ export { SessionContextData, SessionProvider, SessionProviderProps } from './session-provider.js';
1
2
  export { useSession } from './useSession.js';
2
- import 'zustand';
3
+ import 'react/jsx-runtime';
4
+ import 'react';
3
5
  import '@ory/client-fetch';
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ "use client";
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -18,12 +19,15 @@ var __copyProps = (to, from, except, desc) => {
18
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
20
  var client_exports = {};
20
21
  __export(client_exports, {
22
+ SessionProvider: () => import_session_provider.SessionProvider,
21
23
  useSession: () => import_useSession.useSession
22
24
  });
23
25
  module.exports = __toCommonJS(client_exports);
26
+ var import_session_provider = require("./session-provider");
24
27
  var import_useSession = require("./useSession");
25
28
  // Annotate the CommonJS export names for ESM import in node:
26
29
  0 && (module.exports = {
30
+ SessionProvider,
27
31
  useSession
28
32
  });
29
33
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nexport { useSession } from \"./useSession\"\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAA2B;","names":[]}
1
+ {"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["\"use client\"\n// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nexport {\n SessionProvider,\n type SessionContextData,\n type SessionProviderProps,\n} from \"./session-provider\"\nexport { useSession } from \"./useSession\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAIA,8BAIO;AACP,wBAA2B;","names":[]}
@@ -1,5 +1,10 @@
1
+ "use client";
2
+ import {
3
+ SessionProvider
4
+ } from "./session-provider";
1
5
  import { useSession } from "./useSession";
2
6
  export {
7
+ SessionProvider,
3
8
  useSession
4
9
  };
5
10
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nexport { useSession } from \"./useSession\"\n"],"mappings":"AAGA,SAAS,kBAAkB;","names":[]}
1
+ {"version":3,"sources":["../../src/client/index.ts"],"sourcesContent":["\"use client\"\n// Copyright © 2024 Ory Corp\n// SPDX-License-Identifier: Apache-2.0\n\nexport {\n SessionProvider,\n type SessionContextData,\n type SessionProviderProps,\n} from \"./session-provider\"\nexport { useSession } from \"./useSession\"\n"],"mappings":";AAIA;AAAA,EACE;AAAA,OAGK;AACP,SAAS,kBAAkB;","names":[]}