Skip to content

Commit

Permalink
fix: return
Browse files Browse the repository at this point in the history
  • Loading branch information
lotharking committed Dec 13, 2024
1 parent 04b345f commit 37c335a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 48 deletions.
3 changes: 1 addition & 2 deletions examples/chatbot/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export const rootMenuAsQA = {
{ id: 'poll', text: '⚽ World Cup poll' },
{ id: 'rocky', text: '💪 Rocky quotes' },
{ id: 'issue', text: 'Issue credential' },
{ id: 'revoke', text: 'Revoke credential' },
{ id: 'proof', text: 'Request proof' },
{ id: 'help', text: '🆘 Help' },
],
Expand Down Expand Up @@ -100,4 +99,4 @@ export const rockyQuotes = [
'I must break you!',
'Yo, Adrian, I did it!',
"It ain't about how hard you hit. It's about how hard you can get hit and keep moving forward; how much you can take and keep moving forward. That's how winning is done!",
]
]
49 changes: 3 additions & 46 deletions examples/chatbot/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ app.set('json spaces', 2)
const expressHandler = new ExpressEventHandler(app)

let phoneNumberCredentialDefinitionId: string | undefined
let phoneNumberRevocationDefinitionId: string | undefined
let phoneNumberRevocationCount: number = 0

type OngoingCall = {
wsUrl: string
Expand All @@ -85,19 +83,9 @@ const server = app.listen(PORT, async () => {
)

try {
const credentialDefinition = (await apiClient.credentialTypes.create({
id: randomUUID(),
name: "phoneNumber",
version: '1.0',
attributes: ['phoneNumber']
}))
// const credentialDefinition = (await apiClient.credentialTypes.import(phoneCredDefData))
phoneNumberCredentialDefinitionId =
phoneNumberCredentialType?.id ?? credentialDefinition.id
phoneNumberRevocationDefinitionId =
phoneNumberCredentialType?.revocationId ?? credentialDefinition.revocationId
phoneNumberCredentialType?.id ?? (await apiClient.credentialTypes.import(phoneCredDefData)).id
logger.info(`phoneNumberCredentialDefinitionId: ${phoneNumberCredentialDefinitionId}`)
logger.info(`phoneNumberCredentialDefinitionId: ${phoneNumberRevocationDefinitionId}`)
} catch (error) {
logger.error(`Could not create or retrieve phone number credential type: ${error}`)
}
Expand Down Expand Up @@ -166,33 +154,7 @@ const handleMenuSelection = async (options: { connectionId: string; item: string

// Issue credential
if (selectedItem === 'issue' || selectedItem === 'Issue credential') {
if (!phoneNumberCredentialDefinitionId || phoneNumberCredentialDefinitionId === '' ||
!phoneNumberRevocationDefinitionId || phoneNumberRevocationDefinitionId === '') {
await sendTextMessage({
connectionId,
content: 'Service not available',
})
} else {
const body = new CredentialIssuanceMessage({
connectionId,
credentialDefinitionId: phoneNumberCredentialDefinitionId,
claims: [
{
name: 'phoneNumber',
mimeType: 'text/plain',
value: '+5712345678',
},
],
revocationDefinitionId: phoneNumberRevocationDefinitionId,
revocationRegistryIndex: phoneNumberRevocationCount += 1,
})
await apiClient.messages.send(body)
}
}

if (selectedItem === 'revoke' || selectedItem === 'Revoke credential') {
if (!phoneNumberCredentialDefinitionId || phoneNumberCredentialDefinitionId === '' ||
!phoneNumberRevocationDefinitionId || phoneNumberRevocationDefinitionId === '') {
if (!phoneNumberCredentialDefinitionId || phoneNumberCredentialDefinitionId === '') {
await sendTextMessage({
connectionId,
content: 'Service not available',
Expand All @@ -208,8 +170,6 @@ const handleMenuSelection = async (options: { connectionId: string; item: string
value: '+5712345678',
},
],
revocationDefinitionId: phoneNumberRevocationDefinitionId,
revocationRegistryIndex: phoneNumberRevocationCount,
})
await apiClient.messages.send(body)
}
Expand Down Expand Up @@ -423,9 +383,6 @@ expressHandler.messageReceived(async (req, res) => {
const body = new CallOfferRequestMessage({
connectionId: obj.connectionId,
description: 'Start call',
offerExpirationTime: new Date(
Date.now() + 60 * 1000,
),
parameters: { wsUrl, roomId, peerId },
})
await apiClient.messages.send(body)
Expand Down Expand Up @@ -582,4 +539,4 @@ app.put('/call-failure/:connectionId', (req, res) => {
)
})

export { app, server }
export { app, server }

0 comments on commit 37c335a

Please sign in to comment.