Skip to content

Commit

Permalink
fix(security): update authentication and registration flows to be com…
Browse files Browse the repository at this point in the history
…patible with Ory Kratos `1.3.0`
  • Loading branch information
azasypkin committed Sep 29, 2024
1 parent 10eb384 commit 42a511f
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 25 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@emotion/css": "^11.13.0",
"@emotion/react": "^11.13.0",
"@monaco-editor/react": "^4.6.0",
"@ory/client": "^1.14.3",
"@ory/client": "^1.15.4",
"axios": "^1.7.4",
"moment": "^2.30.1",
"nanoid": "^5.0.7",
Expand Down
7 changes: 3 additions & 4 deletions src/app_container/settings_flyout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,9 @@ export function SettingsFlyout({ onClose }: Props) {
throw new Error('Cannot set passkey.');
}

const { publicKey } = JSON.parse(
// Trim `window.__oryWebAuthnRegistration(...)`
((publicKeyNode.attributes as UiNodeInputAttributes).onclick as string).slice(33, -1),
) as { publicKey: SerializedPublicKeyCredentialCreationOptions };
const { publicKey } = JSON.parse((publicKeyNode.attributes as UiNodeInputAttributes).value as string) as {
publicKey: SerializedPublicKeyCredentialCreationOptions;
};

try {
await api.updateSettingsFlow({
Expand Down
11 changes: 5 additions & 6 deletions src/pages/signin/confirm_access_modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,11 @@ export default function ConfirmAccessModal({ email, action, onClose }: ConfirmAc
throw axiosResponse;
}

const publicKey = // Trim `window.__oryWebAuthnLogin(...)`
(
JSON.parse(((publicKeyNode.attributes as UiNodeInputAttributes).onclick as string).slice(26, -1)) as {
publicKey: SerializedPublicKeyCredentialRequestOptions;
}
).publicKey;
const publicKey = (
JSON.parse((publicKeyNode.attributes as UiNodeInputAttributes).value as string) as {
publicKey: SerializedPublicKeyCredentialRequestOptions;
}
).publicKey;

await api.updateLoginFlow({
flow: updatedFlow.id,
Expand Down
11 changes: 5 additions & 6 deletions src/pages/signin/signin_page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,11 @@ export function SigninPage() {
throw axiosResponse;
}

const publicKey = // Trim `window.__oryWebAuthnLogin(...)`
(
JSON.parse(((publicKeyNode.attributes as UiNodeInputAttributes).onclick as string).slice(26, -1)) as {
publicKey: SerializedPublicKeyCredentialRequestOptions;
}
).publicKey;
const publicKey = (
JSON.parse((publicKeyNode.attributes as UiNodeInputAttributes).value as string) as {
publicKey: SerializedPublicKeyCredentialRequestOptions;
}
).publicKey;

await api.updateLoginFlow({
flow: updatedFlow.id,
Expand Down
7 changes: 3 additions & 4 deletions src/pages/signup/signup_page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,9 @@ export function SignupPage() {
throw axiosResponse;
}

const { publicKey } = JSON.parse(
// Trim `window.__oryWebAuthnRegistration(...)`
((publicKeyNode.attributes as UiNodeInputAttributes).onclick as string).slice(33, -1),
) as { publicKey: SerializedPublicKeyCredentialCreationOptions };
const { publicKey } = JSON.parse((publicKeyNode.attributes as UiNodeInputAttributes).value as string) as {
publicKey: SerializedPublicKeyCredentialCreationOptions;
};

await api.updateRegistrationFlow({
flow: updatedFlow.id,
Expand Down

0 comments on commit 42a511f

Please sign in to comment.