From 37c335a23b921b77773514f8fa6fea2d8f1df6e1 Mon Sep 17 00:00:00 2001 From: Andres Vallecilla Date: Fri, 13 Dec 2024 10:34:59 -0500 Subject: [PATCH] fix: return --- examples/chatbot/data.ts | 3 +-- examples/chatbot/index.ts | 49 +++------------------------------------ 2 files changed, 4 insertions(+), 48 deletions(-) diff --git a/examples/chatbot/data.ts b/examples/chatbot/data.ts index 3e8e97e..48581e1 100644 --- a/examples/chatbot/data.ts +++ b/examples/chatbot/data.ts @@ -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' }, ], @@ -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!", -] +] \ No newline at end of file diff --git a/examples/chatbot/index.ts b/examples/chatbot/index.ts index d498b3a..d23ed10 100644 --- a/examples/chatbot/index.ts +++ b/examples/chatbot/index.ts @@ -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 @@ -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}`) } @@ -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', @@ -208,8 +170,6 @@ const handleMenuSelection = async (options: { connectionId: string; item: string value: '+5712345678', }, ], - revocationDefinitionId: phoneNumberRevocationDefinitionId, - revocationRegistryIndex: phoneNumberRevocationCount, }) await apiClient.messages.send(body) } @@ -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) @@ -582,4 +539,4 @@ app.put('/call-failure/:connectionId', (req, res) => { ) }) -export { app, server } +export { app, server } \ No newline at end of file