@ory/elements-react 1.0.0-next.39 → 1.0.0-next.40

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/dist/index.mjs CHANGED
@@ -261,6 +261,8 @@ function parseStateFromFlow(flow) {
261
261
  break;
262
262
  case FlowType.Settings:
263
263
  return { current: "settings" };
264
+ case FlowType.OAuth2Consent:
265
+ return { current: "method_active", method: "oauth2_consent" };
264
266
  }
265
267
  console.warn(
266
268
  `[Ory/Elements React] Encountered an unknown form state on ${flow.flowType} flow with ID ${flow.flow.id}`
@@ -374,6 +376,22 @@ function computeDefaultValues(nodes) {
374
376
  if (attrs.name === "method" || attrs.type === "submit" || typeof attrs.value === "undefined") {
375
377
  return acc;
376
378
  }
379
+ if (attrs.name.startsWith("grant_scope")) {
380
+ const scope = attrs.value;
381
+ if (Array.isArray(acc.grant_scope)) {
382
+ return {
383
+ ...acc,
384
+ // We want to have all scopes accepted by default, so that the user has to actively uncheck them.
385
+ grant_scope: [...acc.grant_scope, scope]
386
+ };
387
+ } else if (!acc.grant_scope) {
388
+ return {
389
+ ...acc,
390
+ grant_scope: [scope]
391
+ };
392
+ }
393
+ return acc;
394
+ }
377
395
  return unrollTrait(
378
396
  {
379
397
  name: attrs.name,
@@ -823,6 +841,19 @@ function useOryFormSubmit(onAfterSubmit) {
823
841
  });
824
842
  break;
825
843
  }
844
+ case FlowType.OAuth2Consent: {
845
+ const response = await fetch(flowContainer.flow.ui.action, {
846
+ method: "POST",
847
+ body: JSON.stringify(data),
848
+ headers: {
849
+ "Content-Type": "application/json"
850
+ }
851
+ });
852
+ const oauth2Success = await response.json();
853
+ if (oauth2Success.redirect_to && typeof oauth2Success.redirect_to === "string") {
854
+ onRedirect(oauth2Success.redirect_to);
855
+ }
856
+ }
826
857
  }
827
858
  if ("password" in data) {
828
859
  methods.setValue("password", "");
@@ -910,7 +941,7 @@ var NodeInput = ({
910
941
  }) => {
911
942
  var _a;
912
943
  const { Node: Node2 } = useComponents();
913
- const { setValue } = useFormContext();
944
+ const { setValue, watch } = useFormContext();
914
945
  const {
915
946
  onloadTrigger,
916
947
  onclickTrigger,
@@ -923,7 +954,10 @@ var NodeInput = ({
923
954
  const isResendNode = ((_a = node.meta.label) == null ? void 0 : _a.id) === 1070008;
924
955
  const isScreenSelectionNode = "name" in node.attributes && node.attributes.name === "screen";
925
956
  const setFormValue = () => {
926
- if (attrs.value && !(isResendNode || isScreenSelectionNode)) {
957
+ if (isResendNode || isScreenSelectionNode || node.group === UiNodeGroupEnum.Oauth2Consent) {
958
+ return;
959
+ }
960
+ if (attrs.value !== void 0) {
927
961
  setValue(attrs.name, attrs.value);
928
962
  }
929
963
  };
@@ -948,6 +982,19 @@ var NodeInput = ({
948
982
  };
949
983
  const isSocial = (attrs.name === "provider" || attrs.name === "link") && (node.group === UiNodeGroupEnum.Oidc || node.group === UiNodeGroupEnum.Saml);
950
984
  const isPinCodeInput = attrs.name === "code" && node.group === "code" || attrs.name === "totp_code" && node.group === "totp";
985
+ const handleScopeChange = (checked) => {
986
+ const scopes = watch("grant_scope");
987
+ if (Array.isArray(scopes)) {
988
+ if (checked) {
989
+ setValue("grant_scope", Array.from(/* @__PURE__ */ new Set([...scopes, attrs.value])));
990
+ } else {
991
+ setValue(
992
+ "grant_scope",
993
+ scopes.filter((scope) => scope !== attrs.value)
994
+ );
995
+ }
996
+ }
997
+ };
951
998
  switch (attributes.type) {
952
999
  case UiNodeInputAttributesTypeEnum.Submit:
953
1000
  case UiNodeInputAttributesTypeEnum.Button:
@@ -957,6 +1004,9 @@ var NodeInput = ({
957
1004
  if (isResendNode || isScreenSelectionNode) {
958
1005
  return null;
959
1006
  }
1007
+ if (node.group === "oauth2_consent") {
1008
+ return null;
1009
+ }
960
1010
  return /* @__PURE__ */ jsx(
961
1011
  Node2.Label,
962
1012
  {
@@ -968,6 +1018,21 @@ var NodeInput = ({
968
1018
  case UiNodeInputAttributesTypeEnum.DatetimeLocal:
969
1019
  throw new Error("Not implemented");
970
1020
  case UiNodeInputAttributesTypeEnum.Checkbox:
1021
+ if (node.group === "oauth2_consent" && node.attributes.node_type === "input") {
1022
+ switch (node.attributes.name) {
1023
+ case "grant_scope":
1024
+ return /* @__PURE__ */ jsx(
1025
+ Node2.ConsentScopeCheckbox,
1026
+ {
1027
+ attributes: attrs,
1028
+ node,
1029
+ onCheckedChange: handleScopeChange
1030
+ }
1031
+ );
1032
+ default:
1033
+ return null;
1034
+ }
1035
+ }
971
1036
  return /* @__PURE__ */ jsx(
972
1037
  Node2.Label,
973
1038
  {
@@ -1056,7 +1121,9 @@ function OryFormSocialButtonsForm() {
1056
1121
  const {
1057
1122
  flow: { ui }
1058
1123
  } = useOryFlow();
1059
- const filteredNodes = ui.nodes.filter((node) => node.group === "oidc");
1124
+ const filteredNodes = ui.nodes.filter(
1125
+ (node) => node.group === UiNodeGroupEnum.Saml || node.group === UiNodeGroupEnum.Oidc
1126
+ );
1060
1127
  if (filteredNodes.length === 0) {
1061
1128
  return null;
1062
1129
  }
@@ -1230,6 +1297,19 @@ function OryFormSectionInner({
1230
1297
  }
1231
1298
  );
1232
1299
  }
1300
+ function OryConsentCard() {
1301
+ const { Form, Card } = useComponents();
1302
+ const flow = useOryFlow();
1303
+ return /* @__PURE__ */ jsxs(OryCard, { children: [
1304
+ /* @__PURE__ */ jsx(OryCardHeader, {}),
1305
+ /* @__PURE__ */ jsx(OryCardContent, { children: /* @__PURE__ */ jsxs(OryForm, { children: [
1306
+ /* @__PURE__ */ jsx(Card.Divider, {}),
1307
+ /* @__PURE__ */ jsx(Form.Group, { children: flow.flow.ui.nodes.map((node, k) => /* @__PURE__ */ jsx(Node, { node }, k)) }),
1308
+ /* @__PURE__ */ jsx(Card.Divider, {}),
1309
+ /* @__PURE__ */ jsx(OryCardFooter, {})
1310
+ ] }) })
1311
+ ] });
1312
+ }
1233
1313
  function OryFormGroupDivider() {
1234
1314
  const { Card } = useComponents();
1235
1315
  const {
@@ -2029,6 +2109,20 @@ var en_default = {
2029
2109
  "property.username": "username",
2030
2110
  "property.identifier": "identifier",
2031
2111
  "property.code": "code",
2112
+ "consent.title": "Authorize {party}",
2113
+ "consent.subtitle": "A third party application wants to access information associated with your account {identifier}.",
2114
+ "consent.scope.openid.title": "Identity",
2115
+ "consent.scope.openid.description": "Allows the application to verify your identity. This is required for authentication and a trusted login experience.",
2116
+ "consent.scope.offline_access.title": "Offline Access",
2117
+ "consent.scope.offline_access.description": "Allows this application to keep you signed in even when you're not actively using it.",
2118
+ "consent.scope.profile.title": "Profile Information",
2119
+ "consent.scope.profile.description": "Allows access to your basic profile details, including your username, first name, and last name.",
2120
+ "consent.scope.email.title": "Email Address",
2121
+ "consent.scope.email.description": "Retrieve your email address and its verification status.",
2122
+ "consent.scope.address.title": "Physical Address",
2123
+ "consent.scope.address.description": "Access your postal address.",
2124
+ "consent.scope.phone.title": "Phone Number",
2125
+ "consent.scope.phone.description": "Retrieve your phone number and its verification status.",
2032
2126
  "error.title.what-happened": "What happened?",
2033
2127
  "error.title.what-can-i-do": "What can I do?",
2034
2128
  "error.instructions": "Please try again in a few minutes or contact the website operator.",
@@ -2300,6 +2394,20 @@ var de_default = {
2300
2394
  "property.phone": "Telefon",
2301
2395
  "property.code": "Code",
2302
2396
  "property.username": "Benutzername",
2397
+ "consent.title": "Autorisieren {party}",
2398
+ "consent.subtitle": "Eine Drittanbieteranwendung m\xF6chte auf Informationen zugreifen, die mit Ihrem Konto {identifier} verkn\xFCpft sind.",
2399
+ "consent.scope.openid.title": "Identit\xE4t",
2400
+ "consent.scope.openid.description": "Erm\xF6glicht der Anwendung, Ihre Identit\xE4t zu \xFCberpr\xFCfen. Dies ist f\xFCr die Authentifizierung und eine vertrauensw\xFCrdige Login-Erfahrung erforderlich.",
2401
+ "consent.scope.offline_access.title": "Offline-Zugriff",
2402
+ "consent.scope.offline_access.description": "Erm\xF6glicht dieser Anwendung, Sie angemeldet zu lassen, auch wenn Sie sie nicht aktiv nutzen.",
2403
+ "consent.scope.profile.title": "Profilinformationen",
2404
+ "consent.scope.profile.description": "Erm\xF6glicht den Zugriff auf Ihre grundlegenden Profildetails, einschlie\xDFlich Ihres Benutzernamens, Vornamens und Nachnamens.",
2405
+ "consent.scope.email.title": "E-Mail-Adresse",
2406
+ "consent.scope.email.description": "Erm\xF6glicht den Abruf Ihrer E-Mail-Adresse und deren \xDCberpr\xFCfungsstatus.",
2407
+ "consent.scope.address.title": "Physische Adresse",
2408
+ "consent.scope.address.description": "Erm\xF6glicht den Zugriff auf Ihre Postanschrift.",
2409
+ "consent.scope.phone.title": "Telefonnummer",
2410
+ "consent.scope.phone.description": "Erm\xF6glicht den Abruf Ihrer Telefonnummer und deren \xDCberpr\xFCfungsstatus.",
2303
2411
  "error.title.what-happened": "Was ist passiert?",
2304
2412
  "error.footer.copy": "Kopieren",
2305
2413
  "error.footer.text": "Bitte f\xFCgen Sie bei der Meldung dieses Fehlers die folgenden Informationen hinzu:",
@@ -2571,6 +2679,20 @@ var es_default = {
2571
2679
  "property.password": "",
2572
2680
  "property.phone": "",
2573
2681
  "property.username": "",
2682
+ "consent.title": "Autorizar {party}",
2683
+ "consent.subtitle": "Una aplicaci\xF3n de terceros quiere acceder a la informaci\xF3n asociada a su cuenta {identifier}.",
2684
+ "consent.scope.openid.title": "Identidad",
2685
+ "consent.scope.openid.description": "Permite que la aplicaci\xF3n verifique su identidad. Esto es necesario para la autenticaci\xF3n y una experiencia de inicio de sesi\xF3n confiable.",
2686
+ "consent.scope.offline_access.title": "Acceso sin conexi\xF3n",
2687
+ "consent.scope.offline_access.description": "Permite que esta aplicaci\xF3n le mantenga conectado incluso cuando no la est\xE9 utilizando activamente.",
2688
+ "consent.scope.profile.title": "Informaci\xF3n del perfil",
2689
+ "consent.scope.profile.description": "Permite el acceso a los detalles b\xE1sicos de su perfil, incluyendo su nombre de usuario, nombre y apellido.",
2690
+ "consent.scope.email.title": "Direcci\xF3n de correo electr\xF3nico",
2691
+ "consent.scope.email.description": "Recupere su direcci\xF3n de correo electr\xF3nico y su estado de verificaci\xF3n.",
2692
+ "consent.scope.address.title": "Direcci\xF3n f\xEDsica",
2693
+ "consent.scope.address.description": "Acceda a su direcci\xF3n postal.",
2694
+ "consent.scope.phone.title": "N\xFAmero de tel\xE9fono",
2695
+ "consent.scope.phone.description": "Recupere su n\xFAmero de tel\xE9fono y su estado de verificaci\xF3n.",
2574
2696
  "error.action.go-back": "",
2575
2697
  "error.footer.copy": "",
2576
2698
  "error.footer.text": "",
@@ -2842,6 +2964,20 @@ var fr_default = {
2842
2964
  "property.password": "",
2843
2965
  "property.phone": "",
2844
2966
  "property.username": "",
2967
+ "consent.title": "Autoriser {party}",
2968
+ "consent.subtitle": "Une application tierce souhaite acc\xE9der aux informations associ\xE9es \xE0 votre compte {identifier}.",
2969
+ "consent.scope.openid.title": "Identit\xE9",
2970
+ "consent.scope.openid.description": "Permet \xE0 l'application de v\xE9rifier votre identit\xE9. Cela est n\xE9cessaire pour l'authentification et une exp\xE9rience de connexion fiable.",
2971
+ "consent.scope.offline_access.title": "Acc\xE8s hors ligne",
2972
+ "consent.scope.offline_access.description": "Permet \xE0 cette application de vous maintenir connect\xE9 m\xEAme lorsque vous ne l'utilisez pas activement.",
2973
+ "consent.scope.profile.title": "Informations de profil",
2974
+ "consent.scope.profile.description": "Permet l'acc\xE8s aux d\xE9tails de base de votre profil, y compris votre nom d'utilisateur, pr\xE9nom et nom.",
2975
+ "consent.scope.email.title": "Adresse e-mail",
2976
+ "consent.scope.email.description": "R\xE9cup\xE8re votre adresse e-mail et son statut de v\xE9rification.",
2977
+ "consent.scope.address.title": "Adresse physique",
2978
+ "consent.scope.address.description": "Acc\xE8de \xE0 votre adresse postale.",
2979
+ "consent.scope.phone.title": "Num\xE9ro de t\xE9l\xE9phone",
2980
+ "consent.scope.phone.description": "R\xE9cup\xE8re votre num\xE9ro de t\xE9l\xE9phone et son statut de v\xE9rification.",
2845
2981
  "error.action.go-back": "",
2846
2982
  "error.footer.copy": "",
2847
2983
  "error.footer.text": "",
@@ -3113,6 +3249,20 @@ var nl_default = {
3113
3249
  "property.password": "",
3114
3250
  "property.phone": "",
3115
3251
  "property.username": "",
3252
+ "consent.title": "Autoriseren {party}",
3253
+ "consent.subtitle": "Een derde partij applicatie wil toegang tot informatie die aan uw account {identifier} is gekoppeld.",
3254
+ "consent.scope.openid.title": "Identiteit",
3255
+ "consent.scope.openid.description": "Stelt de applicatie in staat uw identiteit te verifi\xEBren. Dit is vereist voor authenticatie en een betrouwbare inlogervaring.",
3256
+ "consent.scope.offline_access.title": "Offline toegang",
3257
+ "consent.scope.offline_access.description": "Stelt deze applicatie in staat u ingelogd te houden, zelfs wanneer u deze niet actief gebruikt.",
3258
+ "consent.scope.profile.title": "Profielinformatie",
3259
+ "consent.scope.profile.description": "Geeft toegang tot uw basisprofielgegevens, inclusief uw gebruikersnaam, voornaam en achternaam.",
3260
+ "consent.scope.email.title": "E-mailadres",
3261
+ "consent.scope.email.description": "Haal uw e-mailadres en de verificatiestatus ervan op.",
3262
+ "consent.scope.address.title": "Fysiek adres",
3263
+ "consent.scope.address.description": "Toegang tot uw postadres.",
3264
+ "consent.scope.phone.title": "Telefoonnummer",
3265
+ "consent.scope.phone.description": "Haal uw telefoonnummer en de verificatiestatus ervan op.",
3116
3266
  "error.action.go-back": "",
3117
3267
  "error.footer.copy": "",
3118
3268
  "error.footer.text": "",
@@ -3384,6 +3534,20 @@ var pl_default = {
3384
3534
  "property.phone": "",
3385
3535
  "property.username": "",
3386
3536
  "property.identifier": "",
3537
+ "consent.title": "Autoryzuj {party}",
3538
+ "consent.subtitle": "Aplikacja trzeciej strony chce uzyska\u0107 dost\u0119p do informacji powi\u0105zanych z Twoim kontem {identifier}.",
3539
+ "consent.scope.openid.title": "To\u017Csamo\u015B\u0107",
3540
+ "consent.scope.openid.description": "Pozwala aplikacji zweryfikowa\u0107 Twoj\u0105 to\u017Csamo\u015B\u0107. Jest to wymagane do uwierzytelniania i zapewnienia zaufanej sesji logowania.",
3541
+ "consent.scope.offline_access.title": "Dost\u0119p offline",
3542
+ "consent.scope.offline_access.description": "Pozwala aplikacji utrzyma\u0107 Twoje logowanie, nawet gdy nie korzystasz z niej aktywnie.",
3543
+ "consent.scope.profile.title": "Informacje profilowe",
3544
+ "consent.scope.profile.description": "Pozwala na dost\u0119p do podstawowych danych profilowych, w tym nazwy u\u017Cytkownika, imienia i nazwiska.",
3545
+ "consent.scope.email.title": "Adres e-mail",
3546
+ "consent.scope.email.description": "Pobierz sw\xF3j adres e-mail oraz status jego weryfikacji.",
3547
+ "consent.scope.address.title": "Adres fizyczny",
3548
+ "consent.scope.address.description": "Dost\u0119p do Twojego adresu pocztowego.",
3549
+ "consent.scope.phone.title": "Numer telefonu",
3550
+ "consent.scope.phone.description": "Pobierz sw\xF3j numer telefonu oraz status jego weryfikacji.",
3387
3551
  "error.action.go-back": "",
3388
3552
  "error.footer.copy": "",
3389
3553
  "error.footer.text": "",
@@ -3655,6 +3819,20 @@ var pt_default = {
3655
3819
  "property.password": "",
3656
3820
  "property.phone": "",
3657
3821
  "property.username": "",
3822
+ "consent.title": "Autorizar {party}",
3823
+ "consent.subtitle": "Um aplicativo de terceiros deseja acessar as informa\xE7\xF5es associadas \xE0 sua conta {identifier}.",
3824
+ "consent.scope.openid.title": "Identidade",
3825
+ "consent.scope.openid.description": "Permite que a aplica\xE7\xE3o verifique sua identidade. Isso \xE9 necess\xE1rio para a autentica\xE7\xE3o e uma experi\xEAncia de login confi\xE1vel.",
3826
+ "consent.scope.offline_access.title": "Acesso Offline",
3827
+ "consent.scope.offline_access.description": "Permite que este aplicativo mantenha voc\xEA conectado mesmo quando n\xE3o estiver usando-o ativamente.",
3828
+ "consent.scope.profile.title": "Informa\xE7\xF5es do Perfil",
3829
+ "consent.scope.profile.description": "Permite o acesso aos detalhes b\xE1sicos do seu perfil, incluindo seu nome de usu\xE1rio, primeiro nome e sobrenome.",
3830
+ "consent.scope.email.title": "Endere\xE7o de E-mail",
3831
+ "consent.scope.email.description": "Recupere seu endere\xE7o de e-mail e seu status de verifica\xE7\xE3o.",
3832
+ "consent.scope.address.title": "Endere\xE7o F\xEDsico",
3833
+ "consent.scope.address.description": "Acesse seu endere\xE7o postal.",
3834
+ "consent.scope.phone.title": "N\xFAmero de Telefone",
3835
+ "consent.scope.phone.description": "Recupere seu n\xFAmero de telefone e seu status de verifica\xE7\xE3o.",
3658
3836
  "error.action.go-back": "",
3659
3837
  "error.footer.copy": "",
3660
3838
  "error.footer.text": "",
@@ -3926,6 +4104,20 @@ var sv_default = {
3926
4104
  "property.username": "anv\xE4ndarnamn",
3927
4105
  "property.identifier": "identifier",
3928
4106
  "property.code": "kod",
4107
+ "consent.title": "Auktorisera {party}",
4108
+ "consent.subtitle": "En tredjepartsapplikation vill f\xE5 tillg\xE5ng till information kopplad till ditt konto {identifier}.",
4109
+ "consent.scope.openid.title": "Identitet",
4110
+ "consent.scope.openid.description": "G\xF6r det m\xF6jligt f\xF6r applikationen att verifiera din identitet. Detta kr\xE4vs f\xF6r autentisering och en p\xE5litlig inloggningsupplevelse.",
4111
+ "consent.scope.offline_access.title": "Offline-\xE5tkomst",
4112
+ "consent.scope.offline_access.description": "G\xF6r det m\xF6jligt f\xF6r denna applikation att h\xE5lla dig inloggad \xE4ven n\xE4r du inte aktivt anv\xE4nder den.",
4113
+ "consent.scope.profile.title": "Profilinformation",
4114
+ "consent.scope.profile.description": "Ger tillg\xE5ng till dina grundl\xE4ggande profiluppgifter, inklusive ditt anv\xE4ndarnamn, f\xF6rnamn och efternamn.",
4115
+ "consent.scope.email.title": "E-postadress",
4116
+ "consent.scope.email.description": "H\xE4mta din e-postadress och dess verifieringsstatus.",
4117
+ "consent.scope.address.title": "Fysisk adress",
4118
+ "consent.scope.address.description": "F\xE5 \xE5tkomst till din postadress.",
4119
+ "consent.scope.phone.title": "Telefonnummer",
4120
+ "consent.scope.phone.description": "H\xE4mta ditt telefonnummer och dess verifieringsstatus.",
3929
4121
  "error.action.go-back": "",
3930
4122
  "error.footer.copy": "",
3931
4123
  "error.footer.text": "",
@@ -3946,6 +4138,6 @@ var OryLocales = {
3946
4138
  sv: sv_default
3947
4139
  };
3948
4140
 
3949
- export { HeadlessPageHeader, OryCard, OryCardContent, OryCardFooter, OryCardHeader, OryCardValidationMessages, OryForm, OryFormGroupDivider, OryFormGroups, OryFormOidcButtons, OryFormSection, OryFormSocialButtonsForm, OryLocales, OryProvider, OrySettingsCard, OryTwoStepCard, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryFlow };
4141
+ export { HeadlessPageHeader, OryCard, OryCardContent, OryCardFooter, OryCardHeader, OryCardValidationMessages, OryConsentCard, OryForm, OryFormGroupDivider, OryFormGroups, OryFormOidcButtons, OryFormSection, OryFormSocialButtonsForm, OryLocales, OryProvider, OrySettingsCard, OryTwoStepCard, messageTestId, uiTextToFormattedMessage, useComponents, useNodeSorter, useOryFlow };
3950
4142
  //# sourceMappingURL=index.mjs.map
3951
4143
  //# sourceMappingURL=index.mjs.map