Skip to content

Commit

Permalink
fix: cacao to siwx data parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
zoruka committed Nov 13, 2024
1 parent f2fcb2c commit dddf0bd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
17 changes: 15 additions & 2 deletions packages/appkit/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ export class AppKit {

const siwx = SIWXUtil.getSIWX()

if (siwx && this.universalProvider) {
if (siwx && this.universalProvider && this.chainNamespaces.length === 1) {
// Ignores chainId and account address to get other message data
const siwxMessage = await siwx.createMessage({
chainId: '',
Expand Down Expand Up @@ -750,7 +750,20 @@ export class AppKit {
})

return {
data: siwxMessage,
data: {
accountAddress: cacao.p.iss.split(':').slice(-1).join(''),
chainId: cacao.p.iss.split(':').slice(2, 3).join(''),
uri: cacao.p.aud,
domain: cacao.p.domain,
nonce: cacao.p.nonce,
version: cacao.p.version || siwxMessage.version,
expirationTime: cacao.p.exp,
statement: cacao.p.statement,
issuedAt: cacao.p.iat,
notBefore: cacao.p.nbf,
requestId: cacao.p.requestId,
resources: cacao.p.resources
},
message: message || '',
signature: cacao.s.s,
cacao
Expand Down
9 changes: 1 addition & 8 deletions packages/siwe/src/mapToSIWX.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,7 @@ export async function mapToSIWX(siwe: SIWEConfig): Promise<SIWXConfig> {
{
chainNamespace: 'eip155',
shouldVerify: session => session.data.chainId.startsWith('eip155'),
verify: async session => {
const success = await siwe.verifyMessage({
message: session.message.toString(),
signature: session.signature
})

return success
}
verify: siwe.verifyMessage.bind(siwe)
}
],

Expand Down

0 comments on commit dddf0bd

Please sign in to comment.