Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passkey_fixed #198

Merged
merged 4 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sdk/packages/cloud/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nightlylabs/nightly-cloud",
"version": "0.0.9",
"version": "0.0.13",
"type": "module",
"exports": {
".": {
Expand Down
26 changes: 22 additions & 4 deletions sdk/packages/cloud/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ export class NightlyCloud {
EndpointType.Public,
request
)) as HttpRegisterWithPasskeyStartResponse

// @ts-expect-error Fixes in direct parsing of the response
response.publicKey.challenge = Buffer.from(response.publicKey.challenge, 'base64')
// @ts-expect-error Fixes in direct parsing of the response
response.publicKey.user.id = Buffer.from(response.publicKey.user.id, 'base64')
return response
}

Expand Down Expand Up @@ -266,7 +269,14 @@ export class NightlyCloud {
EndpointType.Public,
request
)) as HttpLoginWithPasskeyStartResponse

// @ts-expect-error Fixes in direct parsing of the response
response.publicKey.challenge = Buffer.from(response.publicKey.challenge, 'base64')
if (response.publicKey.allowCredentials) {
response.publicKey.allowCredentials.forEach((c) => {
// @ts-expect-error Fixes in direct parsing of the response
c.id = Buffer.from(c.id, 'base64')
})
}
return response
}

Expand Down Expand Up @@ -337,6 +347,10 @@ export class NightlyCloud {
EndpointType.Public,
request
)) as HttpResetPasskeyStartResponse
// @ts-expect-error Fixes in direct parsing of the response
response.publicKey.challenge = Buffer.from(response.publicKey.challenge, 'base64')
// @ts-expect-error Fixes in direct parsing of the response
response.publicKey.user.id = Buffer.from(response.publicKey.user.id, 'base64')

return response
}
Expand All @@ -363,6 +377,10 @@ export class NightlyCloud {
EndpointType.Private,
{}
)) as HttpAddNewPasskeyStartResponse
// @ts-expect-error Fixes in direct parsing of the response
response.publicKey.challenge = Buffer.from(response.publicKey.challenge, 'base64')
// @ts-expect-error Fixes in direct parsing of the response
response.publicKey.user.id = Buffer.from(response.publicKey.user.id, 'base64')

return response
}
Expand Down Expand Up @@ -567,10 +585,10 @@ export class NightlyCloud {
EndpointType.Private
)) as HttpGetPasskeyChallengeResponse

// @ts-expect-error
// @ts-expect-error Fixes in direct parsing of the response
response.publicKey.challenge = Buffer.from(response.publicKey.challenge, 'base64')
response.publicKey.allowCredentials?.forEach((c) => {
// @ts-expect-error
// @ts-expect-error Fixes in direct parsing of the response
c.id = Buffer.from(c.id, 'base64')
})
return response
Expand Down
4 changes: 2 additions & 2 deletions server/src/http/cloud/login/login_with_passkey_finish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub struct HttpLoginWithPasskeyFinishRequest {
#[garde(email)]
pub email: String,
#[garde(skip)]
pub passkey_credential: PublicKeyCredential,
pub credential: PublicKeyCredential,
#[garde(skip)]
pub enforce_ip: bool,
}
Expand Down Expand Up @@ -64,7 +64,7 @@ pub async fn login_with_passkey_finish(

// Finish passkey authentication
if let Err(err) = web_auth.finish_passkey_authentication(
&request.passkey_credential,
&request.credential,
&session_data.passkey_verification_state,
) {
warn!(
Expand Down
Loading