Skip to content

Commit c6c2d78

Browse files
committed
Upgrade @ory/hydra-client npm package
Signed-off-by: Dom Del Nano <ddelnano@gmail.com>
1 parent bd6e26f commit c6c2d78

3 files changed

Lines changed: 84 additions & 25 deletions

File tree

src/ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
"@mui/styles": "^5.1.0",
9494
"@mui/system": "^5.1.0",
9595
"@mui/utils": "^5.4.4",
96-
"@ory/kratos-client": "^v0.10.1",
96+
"@ory/kratos-client": "^1.3.8",
9797
"announcekit-react": "^3.1.1",
9898
"apollo3-cache-persist": "^0.9.1",
9999
"app": "link:./src",

src/ui/src/pages/auth/hydra-oauth-provider.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type * as React from 'react';
2020

2121
import {
2222
UiNode, UiNodeAttributes, UiNodeGroupEnum, UiNodeInputAttributes,
23-
UiNodeTypeEnum, V0alpha2ApiFactory,
23+
FrontendApiFactory,
2424
} from '@ory/kratos-client';
2525
import { UserManager } from 'oidc-client';
2626
import * as QueryString from 'query-string';
@@ -36,7 +36,7 @@ export const PasswordError = new Error('Kratos identity server error: Password m
3636
export const FlowIDError = new Error('Auth server requires a flow parameter in the query string, but none were found.');
3737

3838
const kratosUri = `${location.protocol}//${location.host}/oauth/kratos`;
39-
const kratosClient = V0alpha2ApiFactory(null, kratosUri);
39+
const kratosClient = FrontendApiFactory(null, kratosUri);
4040

4141
// Renders a form with an error and no fields.
4242
const displayErrorFormStructure = (error: Error): FormStructure => ({
@@ -51,32 +51,29 @@ const displayErrorFormStructure = (error: Error): FormStructure => ({
5151
},
5252
});
5353

54-
function isInputAttributes(attr: UiNodeAttributes): attr is UiNodeInputAttributes {
55-
return attr.node_type === UiNodeTypeEnum.Input;
56-
}
57-
5854
function nodeToFormField(node: UiNode): FormField | null {
59-
if (!isInputAttributes(node.attributes)) {
55+
const attr = node.attributes as any;
56+
if (attr.node_type !== 'input') {
6057
return null;
6158
}
6259
// We render our own form button.
63-
if (node.attributes.type === 'submit') {
60+
if (attr.type === 'submit') {
6461
return null;
6562
}
6663
return {
67-
disabled: node.attributes.disabled,
64+
disabled: attr.disabled,
6865
messages: node.messages,
69-
name: node.attributes.name,
70-
pattern: node.attributes.pattern,
71-
required: node.attributes.required,
72-
type: node.attributes.type,
73-
value: node.attributes.value,
66+
name: attr.name,
67+
pattern: attr.pattern,
68+
required: attr.required,
69+
type: attr.type,
70+
value: attr.value,
7471
};
7572
}
7673

7774
function nodesToFormFields(nodes: Array<UiNode>): Array<FormField> {
7875
return nodes
79-
.filter(node => node.type === UiNodeTypeEnum.Input)
76+
.filter(node => node.type === 'input')
8077
.filter(node => node.group === UiNodeGroupEnum.Password || node.group === UiNodeGroupEnum.Default)
8178
.map(nodeToFormField)
8279
.filter(node => node);
@@ -278,7 +275,7 @@ export const HydraClient = {
278275
if (flow == null) {
279276
return displayErrorFormStructure(FlowIDError);
280277
}
281-
const { data } = await kratosClient.getSelfServiceLoginFlow(flow);
278+
const { data } = await kratosClient.getLoginFlow({ id: flow });
282279

283280
return {
284281
action: data.ui.action,
@@ -298,7 +295,7 @@ export const HydraClient = {
298295
if (flow == null) {
299296
return displayErrorFormStructure(FlowIDError);
300297
}
301-
const { data } = await kratosClient.getSelfServiceSettingsFlow(flow);
298+
const { data } = await kratosClient.getSettingsFlow({ id: flow });
302299

303300
return {
304301
action: data.ui.action,
@@ -318,7 +315,7 @@ export const HydraClient = {
318315
if (error == null) {
319316
return displayErrorFormStructure(new Error('server error'));
320317
}
321-
const { data } = await kratosClient.getSelfServiceError(error);
318+
const { data } = await kratosClient.getFlowError({ id: error });
322319

323320
return displayErrorFormStructure(new Error(JSON.stringify(data)));
324321
},

src/ui/yarn.lock

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2733,12 +2733,12 @@ __metadata:
27332733
languageName: node
27342734
linkType: hard
27352735

2736-
"@ory/kratos-client@npm:^v0.10.1":
2737-
version: 0.10.1
2738-
resolution: "@ory/kratos-client@npm:0.10.1"
2736+
"@ory/kratos-client@npm:^1.3.8":
2737+
version: 1.3.8
2738+
resolution: "@ory/kratos-client@npm:1.3.8"
27392739
dependencies:
2740-
axios: ^0.21.4
2741-
checksum: 1c2283629904be0a8ab91a9b7e6c91c277e10f892bbe47a39eb9cbf6940b344477473f16dc93f7b12b265727b8fa033fd8a64bfd1f560179497c4b6ea1146b8d
2740+
axios: ^1.6.1
2741+
checksum: 46a49b5ac8c556c9727997e9e8adb049d06efec13af74606b526760ff58de02eb86515bac724c7995aaa69ce800ad4af4adfdc9021dcbf708c0c4bf8e0cbf215
27422742
languageName: node
27432743
linkType: hard
27442744

@@ -2763,7 +2763,7 @@ __metadata:
27632763
"@mui/styles": ^5.1.0
27642764
"@mui/system": ^5.1.0
27652765
"@mui/utils": ^5.4.4
2766-
"@ory/kratos-client": ^v0.10.1
2766+
"@ory/kratos-client": ^1.3.8
27672767
"@testing-library/react": ^13.2.0
27682768
"@testing-library/react-hooks": ^8.0.0
27692769
"@types/jest": ^27.0.2
@@ -4658,6 +4658,17 @@ __metadata:
46584658
languageName: node
46594659
linkType: hard
46604660

4661+
"axios@npm:^1.6.1":
4662+
version: 1.11.0
4663+
resolution: "axios@npm:1.11.0"
4664+
dependencies:
4665+
follow-redirects: ^1.15.6
4666+
form-data: ^4.0.4
4667+
proxy-from-env: ^1.1.0
4668+
checksum: 0a33dc600b588bfd3111b198d5985527ed89f722817455d7cdb66c1d055e5f8859cc2bebb7320888957fc8458ebe77d5f83af02af9cd260217c91c4e92b6dfb6
4669+
languageName: node
4670+
linkType: hard
4671+
46614672
"b4a@npm:^1.6.4":
46624673
version: 1.6.4
46634674
resolution: "b4a@npm:1.6.4"
@@ -6998,6 +7009,18 @@ __metadata:
69987009
languageName: node
69997010
linkType: hard
70007011

7012+
"es-set-tostringtag@npm:^2.1.0":
7013+
version: 2.1.0
7014+
resolution: "es-set-tostringtag@npm:2.1.0"
7015+
dependencies:
7016+
es-errors: ^1.3.0
7017+
get-intrinsic: ^1.2.6
7018+
has-tostringtag: ^1.0.2
7019+
hasown: ^2.0.2
7020+
checksum: 789f35de4be3dc8d11fdcb91bc26af4ae3e6d602caa93299a8c45cf05d36cc5081454ae2a6d3afa09cceca214b76c046e4f8151e092e6fc7feeb5efb9e794fc6
7021+
languageName: node
7022+
linkType: hard
7023+
70017024
"es-shim-unscopables@npm:^1.0.0":
70027025
version: 1.0.0
70037026
resolution: "es-shim-unscopables@npm:1.0.0"
@@ -8119,6 +8142,16 @@ __metadata:
81198142
languageName: node
81208143
linkType: hard
81218144

8145+
"follow-redirects@npm:^1.15.6":
8146+
version: 1.15.9
8147+
resolution: "follow-redirects@npm:1.15.9"
8148+
peerDependenciesMeta:
8149+
debug:
8150+
optional: true
8151+
checksum: 859e2bacc7a54506f2bf9aacb10d165df78c8c1b0ceb8023f966621b233717dab56e8d08baadc3ad3b9db58af290413d585c999694b7c146aaf2616340c3d2a6
8152+
languageName: node
8153+
linkType: hard
8154+
81228155
"for-each@npm:^0.3.3":
81238156
version: 0.3.3
81248157
resolution: "for-each@npm:0.3.3"
@@ -8153,6 +8186,19 @@ __metadata:
81538186
languageName: node
81548187
linkType: hard
81558188

8189+
"form-data@npm:^4.0.4":
8190+
version: 4.0.4
8191+
resolution: "form-data@npm:4.0.4"
8192+
dependencies:
8193+
asynckit: ^0.4.0
8194+
combined-stream: ^1.0.8
8195+
es-set-tostringtag: ^2.1.0
8196+
hasown: ^2.0.2
8197+
mime-types: ^2.1.12
8198+
checksum: 9b7788836df9fa5a6999e0c02515b001946b2a868cfe53f026c69e2c537a2ff9fbfb8e9d2b678744628f3dc7a2d6e14e4e45dfaf68aa6239727f0bdb8ce0abf2
8199+
languageName: node
8200+
linkType: hard
8201+
81568202
"form-data@npm:~2.3.2":
81578203
version: 2.3.3
81588204
resolution: "form-data@npm:2.3.3"
@@ -8741,6 +8787,15 @@ __metadata:
87418787
languageName: node
87428788
linkType: hard
87438789

8790+
"has-tostringtag@npm:^1.0.2":
8791+
version: 1.0.2
8792+
resolution: "has-tostringtag@npm:1.0.2"
8793+
dependencies:
8794+
has-symbols: ^1.0.3
8795+
checksum: 999d60bb753ad714356b2c6c87b7fb74f32463b8426e159397da4bde5bca7e598ab1073f4d8d4deafac297f2eb311484cd177af242776bf05f0d11565680468d
8796+
languageName: node
8797+
linkType: hard
8798+
87448799
"has-unicode@npm:^2.0.0, has-unicode@npm:^2.0.1":
87458800
version: 2.0.1
87468801
resolution: "has-unicode@npm:2.0.1"
@@ -12692,6 +12747,13 @@ __metadata:
1269212747
languageName: node
1269312748
linkType: hard
1269412749

12750+
"proxy-from-env@npm:^1.1.0":
12751+
version: 1.1.0
12752+
resolution: "proxy-from-env@npm:1.1.0"
12753+
checksum: ed7fcc2ba0a33404958e34d95d18638249a68c430e30fcb6c478497d72739ba64ce9810a24f53a7d921d0c065e5b78e3822759800698167256b04659366ca4d4
12754+
languageName: node
12755+
linkType: hard
12756+
1269512757
"psl@npm:^1.1.33":
1269612758
version: 1.8.0
1269712759
resolution: "psl@npm:1.8.0"

0 commit comments

Comments
 (0)