Skip to content

Commit

Permalink
Merge pull request #198 from nightly-labs/passkey_fixed
Browse files Browse the repository at this point in the history
passkey_fixed
  • Loading branch information
dzlk17 authored Sep 3, 2024
2 parents 716851f + 44b4743 commit 1ad8eb7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
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

0 comments on commit 1ad8eb7

Please sign in to comment.