Skip to content
This repository has been archived by the owner on Aug 16, 2024. It is now read-only.

Commit

Permalink
fix: update login schema
Browse files Browse the repository at this point in the history
  • Loading branch information
xstelea committed Feb 6, 2023
1 parent 0d9475f commit 308b769
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
5 changes: 4 additions & 1 deletion lib/IO/decode-wallet-response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ export const decodeWalletResponse = <R>(
const { discriminator: authDiscriminator, ...auth } = value
if (authDiscriminator === 'usePersona') {
return { ...acc, persona: auth.persona }
} else if (authDiscriminator === 'loginWithChallenge') {
const { persona, ...signedChallenge } = auth
return { ...acc, persona, signedChallenge }
} else {
return { ...acc, login: auth }
return { ...acc, persona: auth.persona }
}
}

Expand Down
6 changes: 3 additions & 3 deletions lib/IO/request-items/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export type Login = {
method: {
input: {}
output: {
auth: Persona
persona: Persona
}
}
}
Expand All @@ -25,9 +25,9 @@ export type Login = {
}
method: {
output: {
auth: {
persona: Persona
signedChallenge: {
challenge: string
persona: Persona
publicKey: string
signature: string
}
Expand Down
10 changes: 5 additions & 5 deletions lib/__tests__/decode-wallet-response.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ describe('decodeWalletResponse', () => {
},
},
expected: {
login: {
persona: {
identityAddress: 'addr_xxx',
label: 'personaLabel',
},
persona: {
identityAddress: 'addr_xxx',
label: 'personaLabel',
},
signedChallenge: {
challenge: 'challenge',
publicKey: 'publicKey',
signature: 'signature',
Expand Down
5 changes: 4 additions & 1 deletion lib/__tests__/wallet-sdk.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,6 @@ describe('sdk flow', () => {
const result = await request

if (result.isErr()) throw new Error('should not get a error response')

expect((result.value as any).ongoingAccounts).toEqual([
{
address:
Expand All @@ -232,6 +231,10 @@ describe('sdk flow', () => {
},
])

expect((result.value as any).persona.identityAddress).toEqual(
'account_tdx_b_1qlu8fdyj77jpmu2mqe4rgh3738jcva4nfd2y2vp675zqgdg72y'
)

expect(outgoingMessageSpy.getFirstValue().metadata).toEqual({
dAppDefinitionAddress: 'radixDashboard',
networkId: 1,
Expand Down

0 comments on commit 308b769

Please sign in to comment.