From f35c36d580772270f63803a977bb29eabe44f892 Mon Sep 17 00:00:00 2001 From: hugoib Date: Wed, 13 Nov 2024 12:00:58 +0100 Subject: [PATCH 01/13] docs init --- docs/service-layer/README.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 docs/service-layer/README.md diff --git a/docs/service-layer/README.md b/docs/service-layer/README.md new file mode 100644 index 0000000..cdb8d0e --- /dev/null +++ b/docs/service-layer/README.md @@ -0,0 +1 @@ +init \ No newline at end of file From 9b4387c97c8813303ae0f6fe80c24784a12232e4 Mon Sep 17 00:00:00 2001 From: hugoib Date: Wed, 13 Nov 2024 14:08:05 +0100 Subject: [PATCH 02/13] added first call --- docs/service-layer/README.md | 98 +++++++++++++++++++++- docs/service-layer/event-architecture.png | Bin 0 -> 23245 bytes 2 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 docs/service-layer/event-architecture.png diff --git a/docs/service-layer/README.md b/docs/service-layer/README.md index cdb8d0e..4d62a03 100644 --- a/docs/service-layer/README.md +++ b/docs/service-layer/README.md @@ -1 +1,97 @@ -init \ No newline at end of file +This document outlines the communication between frontend and the service layer. The frontend calls methods inside the service layer and the service layer replies using events. + +# Index + +- [Service layer description](#Service-Layer-Description) +- [Code examples](#Code-examples) +- [Alice registers with mediator](#Alice-registers-with-mediator) +- [Bob adds contact](#Bob-adds-contact) +- [Bob sends a message routed via mediator](#Bob-sends-router-message) +- [Alice checks status requests](#Alice-checks-messages) +- [Other event channels](#Other-events) + + + +# Service layer description + +The service layer aims to organize the services. A service in this context would be the resolution of a credential offer, a request for a credential issuance or an event to interact with the wallet such as the deletion of a credential. + +![Event architecture](./event-architecture.png 'Event architecture') + +Benefits of this architecture: + +- **Improved security by decoupling components.** The frontend layer doesn't has access to the business logic, ensuring a clear separation between different parts of the system for improved security. + +- **Flexibility.** We could integrate different frontends into the engine, allowing for a versatile and adaptable architecture that can accommodate various user interfaces or requirements. + +- **Performance and scalability.** Asynchronicity is at the core of all communication, which means the system can handle requests without waiting for responses. This approach improves the overall performance and scalability of the system. + +# Code examples + +On the service layer side, there is an instantiation of event methods here: + +- [OID4VCIService.ts](https://github.com/adorsys/eudiw-app/blob/86ef72c949f0a7d00011349051fdb8d58d3f22e8/libs/oid4vc/src/lib/OID4VCIService.ts#L24) + +- [OID4VCService.ts](https://github.com/adorsys/eudiw-app/blob/86ef72c949f0a7d00011349051fdb8d58d3f22e8/libs/oid4vc/src/lib/OID4VCService.ts#L10) + +- [OID4VPService.ts](https://github.com/adorsys/eudiw-app/blob/86ef72c949f0a7d00011349051fdb8d58d3f22e8/libs/oid4vc/src/lib/OID4VPService.ts#L14) + +On the front end layer, an example interacting with the method: OID4VCIService.retrieveCredentialHeaders() can be found here: + +- [Credentials.tsx](https://github.com/adorsys/eudiw-app/blob/86ef72c949f0a7d00011349051fdb8d58d3f22e8/apps/wallet-react/src/pages/credentials/Credentials.tsx#L29) + +# Alice-registers-with-mediator + +This flow currently starts with the scan of a QR code and it is composed of one call: + +- [1. Process mediator OOB](#ProcessMediatorOOB) +- [2. Request credential issuance](#requestCredentialIssuance) + +## ProcessMediatorOOB + +The frontend will send the credential offer string resulting from the QR code scan. The service layer will reply with an acknoledgment or an error. + +![QR Scan](./qr-scan.png 'QR Scan') + +### Example input: + +```json +{ + "oob": "https://mediator.rootsid.cloud?_oob=eyJ0eXBlIjoiaHR0cHM6Ly9kaWRjb21tLm9yZy9vdXQtb2YtYmFuZC8yLjAvaW52aXRhdGlvbiIsImlkIjoiNDM3MmIxODctMDk5Zi00MjYxLWFlZTctZjQwZWM5ZTg3Zjg3IiwiZnJvbSI6ImRpZDpwZWVyOjIuRXo2TFNtczU1NVloRnRobjFXVjhjaURCcFptODZoSzl0cDgzV29qSlVteFBHazFoWi5WejZNa21kQmpNeUI0VFM1VWJiUXc1NHN6bTh5dk1NZjFmdEdWMnNRVllBeGFlV2hFLlNleUpwWkNJNkltNWxkeTFwWkNJc0luUWlPaUprYlNJc0luTWlPaUpvZEhSd2N6b3ZMMjFsWkdsaGRHOXlMbkp2YjNSemFXUXVZMnh2ZFdRaUxDSmhJanBiSW1ScFpHTnZiVzB2ZGpJaVhYMCIsImJvZHkiOnsiZ29hbF9jb2RlIjoicmVxdWVzdC1tZWRpYXRlIiwiZ29hbCI6IlJlcXVlc3RNZWRpYXRlIiwibGFiZWwiOiJNZWRpYXRvciIsImFjY2VwdCI6WyJkaWRjb21tL3YyIl19fQ" +} +``` + +### Example response: + +```json +{ + { + "status": "false", + "message": "Error, format not valid", +} +``` + +```json +{ + { + "status": "true", + "message": "Success", +} +``` + +### Event channel name: + +```bash +ProcessMediatorOOB +``` + + +# Others + +(... to come) + +# Other events + +There are also other events happening inside the app, like the retrieval of already stored credentials, deletion of them, etc... + +A complete description of these calls can be found [here.](./other-events/other-events.md) \ No newline at end of file diff --git a/docs/service-layer/event-architecture.png b/docs/service-layer/event-architecture.png new file mode 100644 index 0000000000000000000000000000000000000000..c553590a7f8e52822c948ff13f43c7c738b58fbc GIT binary patch literal 23245 zcmeHvcT|*1^Cln&>Qzt#R2JTHA_5{wV90SyAP8I)0m&jka%NzN zDnUhZ7+?s>h(ivN^Y#l0!~K5y?YHObo;|yJ^$*84^jqCsRbBPe)BQw6>B_;883l}HFSr7?UZ(;7P?}#-yhKKp6MSIRm}axf@6E`|h6RxIMprQ^24HkHha<0wK>?sB5FN6&2tnw$=j1 zw{35k3btd<12Q;Lui7VUw}7 zH)RtMI4f|LLvlYG8=HjvZ8Ny4tlY2H!T%5(cTlK%a6v(5XJ-ND^8&W^=7K_EVq$`4 z&k3G8#}A(1cW|{q8N2Y?IB;$?^1B^bQwI}!i+d;wTN^g0UE^D}jwl2N2lS!sKU;E| zx>)Rd$;RPVw?GF4p*w;?0%ryPtJhE#X8)bnpgUWyZT4&Ha}rQva1{#|Q!5==3u{vw z2OyfH@C6}>&CmSHogG0*-qhZCQ%qEp^i7gGe}7ZP*2>mi?VhoTspRjEkz68q8j>5X zY;R!-h7=k&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zr(&k)B}?yViyOHer3DBS$u5#kgw?k@_k z|Kloj7S8gZpf?YaDVJJfYbO#QBb|hx{$XC>tz_DOX{btkc|59X0{+*2sPur$qy*XV zt0xT_On*C5;kypfufbvR?G8;3N^ib{{gMqD&Tn^EZkt#Cd3G}w|7Xm$N@D+Sk3(EG zyIW_ru?3+f(6vxwixStQ_TPn)#$o%YaYY}3uLPZZ1$HUozU5t%*g^_a=>HA01!YM9 zD4x5?8N5|8K_A**Rm4oN6&EGAiVMRwPZ!vG0ClU!p8z&*2eV2^@*9RVp# zy8)Xd$L&VMf&$LS+jA2IO|#sFCpS^h<>h77*D|P8GbsJl@sZqEosnM)h@aks!s65@ z%%kk&{H3l!J1>=@-@Eh)=}-ec2y%%ME@m?)>t_fSlzBVm-`hp%7MSC!w_bhlFZ)6| zUp*xP;^0l-JVUO>wGuQR4nd%5#X+GsqkHeDAY?!uuzUF01^sF^3qEKiFwZ9lmQVAd z|7dF7OK|0OZ-FpCl|$&)09dVvDw!WWyNSAY^%Of;Dlh%oMv>2UZ*{uXJWK&P;DY~T zVva!|G0>G~6NTR3K6?}(?tH{`soantu^-`M(PK)6dBTexEL&*3A%mZLP}Px9K$xL* zr4J;^C`~*BJvv=lsS>D%V2Xc3H2K;K$^|WhVMZ~J5Av?woqNA=&T`Z19hGMbeP16X zc0R+XqMVl;n`A1Hb!~A|D*Pr^&zM6}L8Ffq+{`pk}cM zXXtKv2`*W4rlwKCx@JaV?lBeuTT3Whk7L|^O!VMK8X%y(E6+R`H)>U_B5^J!MdldBnH^5$qObL==n@ZCr}caACz)=MuB6&&4nmj;cq2Ch-iQNsZ5RWxXtF zzbOivkT57*U5ewLY$$u=o>mi`@zjO(AJ=~ zjc=JgL4tS!Z8-+W)U@xXw&^EZO Date: Thu, 14 Nov 2024 12:55:06 +0100 Subject: [PATCH 03/13] added docu info --- docs/service-layer/README.md | 128 +++++++++++++++++++++++++++-- docs/service-layer/other-events.md | 17 ++++ 2 files changed, 136 insertions(+), 9 deletions(-) create mode 100644 docs/service-layer/other-events.md diff --git a/docs/service-layer/README.md b/docs/service-layer/README.md index 4d62a03..08b36f0 100644 --- a/docs/service-layer/README.md +++ b/docs/service-layer/README.md @@ -6,12 +6,10 @@ This document outlines the communication between frontend and the service layer. - [Code examples](#Code-examples) - [Alice registers with mediator](#Alice-registers-with-mediator) - [Bob adds contact](#Bob-adds-contact) -- [Bob sends a message routed via mediator](#Bob-sends-router-message) +- [Bob sends a message routed via mediator](#Bob-sends-a-message-routed-via-mediator) - [Alice checks status requests](#Alice-checks-messages) - [Other event channels](#Other-events) - - # Service layer description The service layer aims to organize the services. A service in this context would be the resolution of a credential offer, a request for a credential issuance or an event to interact with the wallet such as the deletion of a credential. @@ -49,7 +47,7 @@ This flow currently starts with the scan of a QR code and it is composed of one ## ProcessMediatorOOB -The frontend will send the credential offer string resulting from the QR code scan. The service layer will reply with an acknoledgment or an error. +The frontend will send the credential offer string resulting from the QR code scan. The service layer will reply with an acknoledgment or an error. ![QR Scan](./qr-scan.png 'QR Scan') @@ -57,7 +55,7 @@ The frontend will send the credential offer string resulting from the QR code sc ```json { - "oob": "https://mediator.rootsid.cloud?_oob=eyJ0eXBlIjoiaHR0cHM6Ly9kaWRjb21tLm9yZy9vdXQtb2YtYmFuZC8yLjAvaW52aXRhdGlvbiIsImlkIjoiNDM3MmIxODctMDk5Zi00MjYxLWFlZTctZjQwZWM5ZTg3Zjg3IiwiZnJvbSI6ImRpZDpwZWVyOjIuRXo2TFNtczU1NVloRnRobjFXVjhjaURCcFptODZoSzl0cDgzV29qSlVteFBHazFoWi5WejZNa21kQmpNeUI0VFM1VWJiUXc1NHN6bTh5dk1NZjFmdEdWMnNRVllBeGFlV2hFLlNleUpwWkNJNkltNWxkeTFwWkNJc0luUWlPaUprYlNJc0luTWlPaUpvZEhSd2N6b3ZMMjFsWkdsaGRHOXlMbkp2YjNSemFXUXVZMnh2ZFdRaUxDSmhJanBiSW1ScFpHTnZiVzB2ZGpJaVhYMCIsImJvZHkiOnsiZ29hbF9jb2RlIjoicmVxdWVzdC1tZWRpYXRlIiwiZ29hbCI6IlJlcXVlc3RNZWRpYXRlIiwibGFiZWwiOiJNZWRpYXRvciIsImFjY2VwdCI6WyJkaWRjb21tL3YyIl19fQ" + "oob": "https://mediator.rootsid.cloud?_oob=eyJ0eXBlIjoiaHR0cHM6Ly9kaWRjb21tLm9yZy9vdXQtb2YtYmFuZC8yLjAvaW52aXRhdGlvbiIsImlkIjoiNDM3MmIxODctMDk5Zi00MjYxLWFlZTctZjQwZWM5ZTg3Zjg3IiwiZnJvbSI6ImRpZDpwZWVyOjIuRXo2TFNtczU1NVloRnRobjFXVjhjaURCcFptODZoSzl0cDgzV29qSlVteFBHazFoWi5WejZNa21kQmpNeUI0VFM1VWJiUXc1NHN6bTh5dk1NZjFmdEdWMnNRVllBeGFlV2hFLlNleUpwWkNJNkltNWxkeTFwWkNJc0luUWlPaUprYlNJc0luTWlPaUpvZEhSd2N6b3ZMMjFsWkdsaGRHOXlMbkp2YjNSemFXUXVZMnh2ZFdRaUxDSmhJanBiSW1ScFpHTnZiVzB2ZGpJaVhYMCIsImJvZHkiOnsiZ29hbF9jb2RlIjoicmVxdWVzdC1tZWRpYXRlIiwiZ29hbCI6IlJlcXVlc3RNZWRpYXRlIiwibGFiZWwiOiJNZWRpYXRvciIsImFjY2VwdCI6WyJkaWRjb21tL3YyIl19fQ" } ``` @@ -85,13 +83,125 @@ The frontend will send the credential offer string resulting from the QR code sc ProcessMediatorOOB ``` +## Bob adds contact + +The frontend will send the did:peer from a QR code scan or a string. The service layer will reply with an acknoledgment or an error. + +![QR Scan](./qr-scan.png 'QR Scan') + +### Example input: + +```json +{ + "peer_did": "did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA" +} +``` + +### Example response: + +```json +{ + { + "status": "false", + "message": "Error, format not valid", +} +``` + +```json +{ + { + "status": "true", + "message": "Success", +} +``` + +### Event channel name: + +```bash +StoreContact +``` + +## Bob sends a message routed via mediator + +The frontend will send the did:peer and the content from the message. The service layer will reply with an acknoledgment or an error. + +### Example input: + +```json +{ + "peer_did": "did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA", + "message": "Hey bob, hope you are doing fine. I miss you." +} +``` + +### Example response: + +```json +{ + { + "status": "false", + "message": "Error, {}", +} +``` + +```json +{ + { + "status": "true", + "message": "Success", +} +``` -# Others +### Event channel name: -(... to come) +```bash +RouteForwardMessages +``` + +## Alice checks status requests + +The frontend will check for new messages. Following an email like structure, the call will be triggered by the FE and not by an indepedneted job on the BE. Reasons: + +User-Driven Polling: In an email-like architecture, checking for new messages is often based on the user's activity—such as opening the chat app or manually refreshing. It’s efficient to trigger the status-request call only when the client is actively requesting it, rather than having a backend job that checks continuously for every user. + +Reduced Server Load: If a backend job is set up to check for new messages frequently, it could increase server load. Frontend-triggered requests help limit the number of status checks to just what’s necessary. + +Real-Time Experience: If you want to add real-time message notifications, a combination of frontend-triggered status-request checks and possibly WebSocket-based updates would allow for a more dynamic experience. + +### Example input: + +```json +{ + "trigger": "true" +} +``` + +### Example response: + +```json +{ + { + "status": "false", + "message": "Error, {}", +} +``` + +```json +{ + { + "status": "true", + "message": "Success", +} +``` + +### Event channel name: + +```bash +ReceiveMessages +``` # Other events -There are also other events happening inside the app, like the retrieval of already stored credentials, deletion of them, etc... +There are also other events happening inside the app, like the retrieval of already messages, deletion of them, etc... -A complete description of these calls can be found [here.](./other-events/other-events.md) \ No newline at end of file +A complete description of these calls can be found [here.](./other-events.md) diff --git a/docs/service-layer/other-events.md b/docs/service-layer/other-events.md new file mode 100644 index 0000000..795cfc1 --- /dev/null +++ b/docs/service-layer/other-events.md @@ -0,0 +1,17 @@ +# Index + +- [Retrieve Messages](#Retrieve-Messages) +- [Retrieve Message Headers](#Retrieve-Message-Headers) +- [Delete Messages](#Delete-Messages) +- [Retrieve DID](#Retrieve-DID) +- [Delete Contact](#Delete-Contact) + +## Retrieve Messages + +## Retrieve Message Headers + +## Delete Messages + +## Retrieve DID + +## Delete Contact From 4aefc578ea9dcc28bf5524a3add7bf3a0df6bf2b Mon Sep 17 00:00:00 2001 From: hugoib Date: Mon, 18 Nov 2024 13:52:18 +0100 Subject: [PATCH 04/13] added last part of documentation --- docs/service-layer/README.md | 57 ++++----- docs/service-layer/other-events.md | 189 +++++++++++++++++++++++++++-- 2 files changed, 203 insertions(+), 43 deletions(-) diff --git a/docs/service-layer/README.md b/docs/service-layer/README.md index 08b36f0..c687775 100644 --- a/docs/service-layer/README.md +++ b/docs/service-layer/README.md @@ -1,30 +1,30 @@ -This document outlines the communication between frontend and the service layer. The frontend calls methods inside the service layer and the service layer replies using events. +This document outlines the communication between the frontend and the service layer. The frontend calls methods inside the service layer and the service layer replies using events. # Index -- [Service layer description](#Service-Layer-Description) -- [Code examples](#Code-examples) +- [Service layer overview](#Service-Layer-Overview) +- [Event code examples](#Event-Code-examples) - [Alice registers with mediator](#Alice-registers-with-mediator) - [Bob adds contact](#Bob-adds-contact) - [Bob sends a message routed via mediator](#Bob-sends-a-message-routed-via-mediator) - [Alice checks status requests](#Alice-checks-messages) - [Other event channels](#Other-events) -# Service layer description +# Service layer overview The service layer aims to organize the services. A service in this context would be the resolution of a credential offer, a request for a credential issuance or an event to interact with the wallet such as the deletion of a credential. -![Event architecture](./event-architecture.png 'Event architecture') +![Event Architecture](./event-architecture.png 'Event architecture') Benefits of this architecture: -- **Improved security by decoupling components.** The frontend layer doesn't has access to the business logic, ensuring a clear separation between different parts of the system for improved security. +- **Improved security by decoupling components.** The frontend lacks access to business logic, enforcing strict separation for improved security. - **Flexibility.** We could integrate different frontends into the engine, allowing for a versatile and adaptable architecture that can accommodate various user interfaces or requirements. - **Performance and scalability.** Asynchronicity is at the core of all communication, which means the system can handle requests without waiting for responses. This approach improves the overall performance and scalability of the system. -# Code examples +# Event code examples On the service layer side, there is an instantiation of event methods here: @@ -38,31 +38,28 @@ On the front end layer, an example interacting with the method: OID4VCIService.r - [Credentials.tsx](https://github.com/adorsys/eudiw-app/blob/86ef72c949f0a7d00011349051fdb8d58d3f22e8/apps/wallet-react/src/pages/credentials/Credentials.tsx#L29) -# Alice-registers-with-mediator +# Alice registers with mediator This flow currently starts with the scan of a QR code and it is composed of one call: -- [1. Process mediator OOB](#ProcessMediatorOOB) -- [2. Request credential issuance](#requestCredentialIssuance) +The backend will be in charge of the calls to the mediator and will only notify the frontend once the mediation coordination has been successful or it has failed. ## ProcessMediatorOOB The frontend will send the credential offer string resulting from the QR code scan. The service layer will reply with an acknoledgment or an error. -![QR Scan](./qr-scan.png 'QR Scan') ### Example input: ```json -{ - "oob": "https://mediator.rootsid.cloud?_oob=eyJ0eXBlIjoiaHR0cHM6Ly9kaWRjb21tLm9yZy9vdXQtb2YtYmFuZC8yLjAvaW52aXRhdGlvbiIsImlkIjoiNDM3MmIxODctMDk5Zi00MjYxLWFlZTctZjQwZWM5ZTg3Zjg3IiwiZnJvbSI6ImRpZDpwZWVyOjIuRXo2TFNtczU1NVloRnRobjFXVjhjaURCcFptODZoSzl0cDgzV29qSlVteFBHazFoWi5WejZNa21kQmpNeUI0VFM1VWJiUXc1NHN6bTh5dk1NZjFmdEdWMnNRVllBeGFlV2hFLlNleUpwWkNJNkltNWxkeTFwWkNJc0luUWlPaUprYlNJc0luTWlPaUpvZEhSd2N6b3ZMMjFsWkdsaGRHOXlMbkp2YjNSemFXUXVZMnh2ZFdRaUxDSmhJanBiSW1ScFpHTnZiVzB2ZGpJaVhYMCIsImJvZHkiOnsiZ29hbF9jb2RlIjoicmVxdWVzdC1tZWRpYXRlIiwiZ29hbCI6IlJlcXVlc3RNZWRpYXRlIiwibGFiZWwiOiJNZWRpYXRvciIsImFjY2VwdCI6WyJkaWRjb21tL3YyIl19fQ" -} + + ProcessMediatorOOB("https://mediator.rootsid.cloud?_oob=eyJ0eXBlIjoiaHR0cHM6Ly9kaWRjb21tLm9yZy9vdXQtb2YtYmFuZC8yLjAvaW52aXRhdGlvbiIsImlkIjoiNDM3MmIxODctMDk5Zi00MjYxLWFlZTctZjQwZWM5ZTg3Zjg3IiwiZnJvbSI6ImRpZDpwZWVyOjIuRXo2TFNtczU1NVloRnRobjFXVjhjaURCcFptODZoSzl0cDgzV29qSlVteFBHazFoWi5WejZNa21kQmpNeUI0VFM1VWJiUXc1NHN6bTh5dk1NZjFmdEdWMnNRVllBeGFlV2hFLlNleUpwWkNJNkltNWxkeTFwWkNJc0luUWlPaUprYlNJc0luTWlPaUpvZEhSd2N6b3ZMMjFsWkdsaGRHOXlMbkp2YjNSemFXUXVZMnh2ZFdRaUxDSmhJanBiSW1ScFpHTnZiVzB2ZGpJaVhYMCIsImJvZHkiOnsiZ29hbF9jb2RlIjoicmVxdWVzdC1tZWRpYXRlIiwiZ29hbCI6IlJlcXVlc3RNZWRpYXRlIiwibGFiZWwiOiJNZWRpYXRvciIsImFjY2VwdCI6WyJkaWRjb21tL3YyIl19fQ") + ``` ### Example response: ```json -{ { "status": "false", "message": "Error, format not valid", @@ -70,7 +67,6 @@ The frontend will send the credential offer string resulting from the QR code sc ``` ```json -{ { "status": "true", "message": "Success", @@ -87,20 +83,16 @@ ProcessMediatorOOB The frontend will send the did:peer from a QR code scan or a string. The service layer will reply with an acknoledgment or an error. -![QR Scan](./qr-scan.png 'QR Scan') - ### Example input: ```json -{ - "peer_did": "did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA" -} +StoreContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA") + ``` ### Example response: ```json -{ { "status": "false", "message": "Error, format not valid", @@ -108,7 +100,6 @@ The frontend will send the did:peer from a QR code scan or a string. The service ``` ```json -{ { "status": "true", "message": "Success", @@ -128,16 +119,14 @@ The frontend will send the did:peer and the content from the message. The servic ### Example input: ```json -{ - "peer_did": "did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA", - "message": "Hey bob, hope you are doing fine. I miss you." -} +RouteForwardMessages(peer_did, message); +example: +RouteForwardMessages("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA", "Hey bob, hope you are doing fine. I miss you."); ``` ### Example response: ```json -{ { "status": "false", "message": "Error, {}", @@ -145,7 +134,6 @@ The frontend will send the did:peer and the content from the message. The servic ``` ```json -{ { "status": "true", "message": "Success", @@ -160,7 +148,7 @@ RouteForwardMessages ## Alice checks status requests -The frontend will check for new messages. Following an email like structure, the call will be triggered by the FE and not by an indepedneted job on the BE. Reasons: +The frontend will check for new messages. Following an email like architecture, the call will be triggered by the FE and not by an independent job on the BE. Reasons: User-Driven Polling: In an email-like architecture, checking for new messages is often based on the user's activity—such as opening the chat app or manually refreshing. It’s efficient to trigger the status-request call only when the client is actively requesting it, rather than having a backend job that checks continuously for every user. @@ -171,15 +159,13 @@ Real-Time Experience: If you want to add real-time message notifications, a comb ### Example input: ```json -{ - "trigger": "true" -} +void ``` +This method receives no input. ### Example response: ```json -{ { "status": "false", "message": "Error, {}", @@ -187,7 +173,6 @@ Real-Time Experience: If you want to add real-time message notifications, a comb ``` ```json -{ { "status": "true", "message": "Success", @@ -202,6 +187,6 @@ ReceiveMessages # Other events -There are also other events happening inside the app, like the retrieval of already messages, deletion of them, etc... +There are also other events happening inside the app, like the retrieval of already existing messages, deletion of them, etc... A complete description of these calls can be found [here.](./other-events.md) diff --git a/docs/service-layer/other-events.md b/docs/service-layer/other-events.md index 795cfc1..f663b16 100644 --- a/docs/service-layer/other-events.md +++ b/docs/service-layer/other-events.md @@ -1,17 +1,192 @@ # Index -- [Retrieve Messages](#Retrieve-Messages) -- [Retrieve Message Headers](#Retrieve-Message-Headers) +- [Retrieve New Messages](#Retrieve-Messages) - [Delete Messages](#Delete-Messages) - [Retrieve DID](#Retrieve-DID) - [Delete Contact](#Delete-Contact) +- [Register Contact](#Register-Contact) -## Retrieve Messages -## Retrieve Message Headers -## Delete Messages +# Retrieve New Messages -## Retrieve DID +This event will bring new messages to the FE, which will be stored in the local storage. There will be a limit on cached messages. The limit will be per conversation. Once there are new messages that exceed the pile, we will delete old ones. -## Delete Contact +## Example logic + +```json + if (cachedMessages.length > maxMessages) { + const prunedMessages = cachedMessages.slice(-maxMessages); + localStorage.setItem(key, JSON.stringify(prunedMessages)); + } +``` +## Example input: + +```json +void +``` + +This method receives no input. + +## Example response: + +```json +{ + "status": "success", + "payload": [ + { + "did": "did:peer(..)", + "contact": "Alice", + "message": {"Hey Peter, bring bread."}, + "id": 3 + }, + { + "did": "did:peer(..)", + "contact": "Bob", + "message": {"Hey Bob, bring butter."}, + "id": 2 + }, + { + "did": "did:peer(..)", + "contact": "Hugo", + "message": {"Hey Jan, bring Salt."}, + "id": 1 + } + ] +} +``` + +## Event channel name: + +```bash +RetrieveMessages +``` + +# Delete Messages + +This event will delete specific messages. + + +## Example input: +```json +DeleteMessages(did, id); +DeleteMessages("did:peer", 3); +``` + +## Example response: + +```json + { + "status": "false", + "message": "Error, format not valid", +} +``` + +```json + { + "status": "true", + "message": "Success", +} +``` + +## Event channel name: + +```bash +DeleteMessages +``` + +# Retrieve DIDWithMediator + +This event will retrieve the DID where the mediator will receive messages for the user. + + +## Example input: +```json +RetrieveDIDWithMediator() +``` + +## Example response: + +```json +{ + "did_for_mediation": "did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA", + "status": "true", + "message": "Success", +} +``` + +```json + { + "status": "false", + "message": "error", +} +``` + +## Event channel name: + +```bash +RetrieveDIDWithMediator +``` + +# Delete Contact + +This event will delete a registered contact. + + +## Example input: +```json +DeleteContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA") +``` + +## Example response: + +```json +{ + "status": "true", + "message": "Success", +} +``` + +```json + { + "status": "false", + "message": "error", +} +``` + +## Event channel name: + +```bash +DeleteContact +``` +# Register contact + +This event will add a new contact. + + +## Example input: +```json +AddContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA") +``` + +## Example response: + +```json +{ + "status": "true", + "message": "Success", +} +``` + +```json + { + "status": "false", + "message": "error", +} +``` + +## Event channel name: + +```bash +AddContact +``` \ No newline at end of file From 4dbbda714a5e99734d6ff701f810228696844010 Mon Sep 17 00:00:00 2001 From: hugoib Date: Mon, 18 Nov 2024 13:56:45 +0100 Subject: [PATCH 05/13] fixed format --- docs/service-layer/README.md | 36 ++++++++++++------------- docs/service-layer/other-events.md | 42 +++++++++++++++--------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/docs/service-layer/README.md b/docs/service-layer/README.md index c687775..4224d43 100644 --- a/docs/service-layer/README.md +++ b/docs/service-layer/README.md @@ -42,13 +42,12 @@ On the front end layer, an example interacting with the method: OID4VCIService.r This flow currently starts with the scan of a QR code and it is composed of one call: -The backend will be in charge of the calls to the mediator and will only notify the frontend once the mediation coordination has been successful or it has failed. +The backend will be in charge of the calls to the mediator and will only notify the frontend once the mediation coordination has been successful or it has failed. ## ProcessMediatorOOB The frontend will send the credential offer string resulting from the QR code scan. The service layer will reply with an acknoledgment or an error. - ### Example input: ```json @@ -60,16 +59,16 @@ The frontend will send the credential offer string resulting from the QR code sc ### Example response: ```json - { +{ "status": "false", - "message": "Error, format not valid", + "message": "Error, format not valid" } ``` ```json - { +{ "status": "true", - "message": "Success", + "message": "Success" } ``` @@ -93,16 +92,16 @@ StoreContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6Mk ### Example response: ```json - { +{ "status": "false", - "message": "Error, format not valid", + "message": "Error, format not valid" } ``` ```json - { +{ "status": "true", - "message": "Success", + "message": "Success" } ``` @@ -127,16 +126,16 @@ RouteForwardMessages("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93 ### Example response: ```json - { +{ "status": "false", - "message": "Error, {}", + "message": "Error, {}" } ``` ```json - { +{ "status": "true", - "message": "Success", + "message": "Success" } ``` @@ -161,21 +160,22 @@ Real-Time Experience: If you want to add real-time message notifications, a comb ```json void ``` + This method receives no input. ### Example response: ```json - { +{ "status": "false", - "message": "Error, {}", + "message": "Error, {}" } ``` ```json - { +{ "status": "true", - "message": "Success", + "message": "Success" } ``` diff --git a/docs/service-layer/other-events.md b/docs/service-layer/other-events.md index f663b16..a95232e 100644 --- a/docs/service-layer/other-events.md +++ b/docs/service-layer/other-events.md @@ -6,11 +6,9 @@ - [Delete Contact](#Delete-Contact) - [Register Contact](#Register-Contact) - - # Retrieve New Messages -This event will bring new messages to the FE, which will be stored in the local storage. There will be a limit on cached messages. The limit will be per conversation. Once there are new messages that exceed the pile, we will delete old ones. +This event will bring new messages to the FE, which will be stored in the local storage. There will be a limit on cached messages. The limit will be per conversation. Once there are new messages that exceed the pile, we will delete old ones. ## Example logic @@ -20,6 +18,7 @@ This event will bring new messages to the FE, which will be stored in the local localStorage.setItem(key, JSON.stringify(prunedMessages)); } ``` + ## Example input: ```json @@ -66,8 +65,8 @@ RetrieveMessages This event will delete specific messages. - ## Example input: + ```json DeleteMessages(did, id); DeleteMessages("did:peer", 3); @@ -76,16 +75,16 @@ DeleteMessages("did:peer", 3); ## Example response: ```json - { +{ "status": "false", - "message": "Error, format not valid", + "message": "Error, format not valid" } ``` ```json - { +{ "status": "true", - "message": "Success", + "message": "Success" } ``` @@ -99,8 +98,8 @@ DeleteMessages This event will retrieve the DID where the mediator will receive messages for the user. - ## Example input: + ```json RetrieveDIDWithMediator() ``` @@ -111,14 +110,14 @@ RetrieveDIDWithMediator() { "did_for_mediation": "did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA", "status": "true", - "message": "Success", + "message": "Success" } ``` ```json - { +{ "status": "false", - "message": "error", + "message": "error" } ``` @@ -132,8 +131,8 @@ RetrieveDIDWithMediator This event will delete a registered contact. - ## Example input: + ```json DeleteContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA") ``` @@ -143,14 +142,14 @@ DeleteContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6M ```json { "status": "true", - "message": "Success", + "message": "Success" } ``` ```json - { +{ "status": "false", - "message": "error", + "message": "error" } ``` @@ -159,12 +158,13 @@ DeleteContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6M ```bash DeleteContact ``` + # Register contact This event will add a new contact. - ## Example input: + ```json AddContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA") ``` @@ -174,14 +174,14 @@ AddContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6Mkrn ```json { "status": "true", - "message": "Success", + "message": "Success" } ``` ```json - { +{ "status": "false", - "message": "error", + "message": "error" } ``` @@ -189,4 +189,4 @@ AddContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6Mkrn ```bash AddContact -``` \ No newline at end of file +``` From 5aee6138e1f54119a657e6edbbe917d4de6d8eba Mon Sep 17 00:00:00 2001 From: hugoib Date: Mon, 18 Nov 2024 14:09:34 +0100 Subject: [PATCH 06/13] fixed md format --- docs/service-layer/README.md | 8 ++++---- docs/service-layer/other-events.md | 10 +++++----- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/service-layer/README.md b/docs/service-layer/README.md index 4224d43..7436c11 100644 --- a/docs/service-layer/README.md +++ b/docs/service-layer/README.md @@ -50,7 +50,7 @@ The frontend will send the credential offer string resulting from the QR code sc ### Example input: -```json +```javascript ProcessMediatorOOB("https://mediator.rootsid.cloud?_oob=eyJ0eXBlIjoiaHR0cHM6Ly9kaWRjb21tLm9yZy9vdXQtb2YtYmFuZC8yLjAvaW52aXRhdGlvbiIsImlkIjoiNDM3MmIxODctMDk5Zi00MjYxLWFlZTctZjQwZWM5ZTg3Zjg3IiwiZnJvbSI6ImRpZDpwZWVyOjIuRXo2TFNtczU1NVloRnRobjFXVjhjaURCcFptODZoSzl0cDgzV29qSlVteFBHazFoWi5WejZNa21kQmpNeUI0VFM1VWJiUXc1NHN6bTh5dk1NZjFmdEdWMnNRVllBeGFlV2hFLlNleUpwWkNJNkltNWxkeTFwWkNJc0luUWlPaUprYlNJc0luTWlPaUpvZEhSd2N6b3ZMMjFsWkdsaGRHOXlMbkp2YjNSemFXUXVZMnh2ZFdRaUxDSmhJanBiSW1ScFpHTnZiVzB2ZGpJaVhYMCIsImJvZHkiOnsiZ29hbF9jb2RlIjoicmVxdWVzdC1tZWRpYXRlIiwiZ29hbCI6IlJlcXVlc3RNZWRpYXRlIiwibGFiZWwiOiJNZWRpYXRvciIsImFjY2VwdCI6WyJkaWRjb21tL3YyIl19fQ") @@ -84,7 +84,7 @@ The frontend will send the did:peer from a QR code scan or a string. The service ### Example input: -```json +```javascript StoreContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA") ``` @@ -117,9 +117,9 @@ The frontend will send the did:peer and the content from the message. The servic ### Example input: -```json +```javascript RouteForwardMessages(peer_did, message); -example: +// example: RouteForwardMessages("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA", "Hey bob, hope you are doing fine. I miss you."); ``` diff --git a/docs/service-layer/other-events.md b/docs/service-layer/other-events.md index a95232e..5a5abff 100644 --- a/docs/service-layer/other-events.md +++ b/docs/service-layer/other-events.md @@ -12,7 +12,7 @@ This event will bring new messages to the FE, which will be stored in the local ## Example logic -```json +```javascript if (cachedMessages.length > maxMessages) { const prunedMessages = cachedMessages.slice(-maxMessages); localStorage.setItem(key, JSON.stringify(prunedMessages)); @@ -67,7 +67,7 @@ This event will delete specific messages. ## Example input: -```json +```javascript DeleteMessages(did, id); DeleteMessages("did:peer", 3); ``` @@ -100,7 +100,7 @@ This event will retrieve the DID where the mediator will receive messages for th ## Example input: -```json +```javascript RetrieveDIDWithMediator() ``` @@ -133,7 +133,7 @@ This event will delete a registered contact. ## Example input: -```json +```javascript DeleteContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA") ``` @@ -165,7 +165,7 @@ This event will add a new contact. ## Example input: -```json +```javascript AddContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA") ``` From a97f0655780e356d9d0a9cc2c8da8441f9a166aa Mon Sep 17 00:00:00 2001 From: hugoib Date: Mon, 18 Nov 2024 14:11:35 +0100 Subject: [PATCH 07/13] fixed md format --- docs/service-layer/README.md | 4 ---- docs/service-layer/other-events.md | 4 ---- 2 files changed, 8 deletions(-) diff --git a/docs/service-layer/README.md b/docs/service-layer/README.md index 7436c11..ceb7b94 100644 --- a/docs/service-layer/README.md +++ b/docs/service-layer/README.md @@ -157,10 +157,6 @@ Real-Time Experience: If you want to add real-time message notifications, a comb ### Example input: -```json -void -``` - This method receives no input. ### Example response: diff --git a/docs/service-layer/other-events.md b/docs/service-layer/other-events.md index 5a5abff..a5c5d84 100644 --- a/docs/service-layer/other-events.md +++ b/docs/service-layer/other-events.md @@ -21,10 +21,6 @@ This event will bring new messages to the FE, which will be stored in the local ## Example input: -```json -void -``` - This method receives no input. ## Example response: From 849f5fd5e09d5a100d7cb6c4678c278ca2ea1c11 Mon Sep 17 00:00:00 2001 From: hugoib Date: Mon, 18 Nov 2024 14:13:08 +0100 Subject: [PATCH 08/13] fixed format --- docs/service-layer/README.md | 16 ++++++++++------ docs/service-layer/other-events.md | 20 ++++++++++++-------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/docs/service-layer/README.md b/docs/service-layer/README.md index ceb7b94..93279dd 100644 --- a/docs/service-layer/README.md +++ b/docs/service-layer/README.md @@ -51,9 +51,9 @@ The frontend will send the credential offer string resulting from the QR code sc ### Example input: ```javascript - - ProcessMediatorOOB("https://mediator.rootsid.cloud?_oob=eyJ0eXBlIjoiaHR0cHM6Ly9kaWRjb21tLm9yZy9vdXQtb2YtYmFuZC8yLjAvaW52aXRhdGlvbiIsIml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ZWwiOiJNZWRpYXRvciIsImFjY2VwdCI6WyJkaWRjb21tL3YyIl19fQ', +); ``` ### Example response: @@ -85,8 +85,9 @@ The frontend will send the did:peer from a QR code scan or a string. The service ### Example input: ```javascript -StoreContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA") - +StoreContact( + 'did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA', +); ``` ### Example response: @@ -120,7 +121,10 @@ The frontend will send the did:peer and the content from the message. The servic ```javascript RouteForwardMessages(peer_did, message); // example: -RouteForwardMessages("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA", "Hey bob, hope you are doing fine. I miss you."); +RouteForwardMessages( + 'did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA', + 'Hey bob, hope you are doing fine. I miss you.', +); ``` ### Example response: diff --git a/docs/service-layer/other-events.md b/docs/service-layer/other-events.md index a5c5d84..5f0f0ba 100644 --- a/docs/service-layer/other-events.md +++ b/docs/service-layer/other-events.md @@ -13,10 +13,10 @@ This event will bring new messages to the FE, which will be stored in the local ## Example logic ```javascript - if (cachedMessages.length > maxMessages) { - const prunedMessages = cachedMessages.slice(-maxMessages); - localStorage.setItem(key, JSON.stringify(prunedMessages)); - } +if (cachedMessages.length > maxMessages) { + const prunedMessages = cachedMessages.slice(-maxMessages); + localStorage.setItem(key, JSON.stringify(prunedMessages)); +} ``` ## Example input: @@ -65,7 +65,7 @@ This event will delete specific messages. ```javascript DeleteMessages(did, id); -DeleteMessages("did:peer", 3); +DeleteMessages('did:peer', 3); ``` ## Example response: @@ -97,7 +97,7 @@ This event will retrieve the DID where the mediator will receive messages for th ## Example input: ```javascript -RetrieveDIDWithMediator() +RetrieveDIDWithMediator(); ``` ## Example response: @@ -130,7 +130,9 @@ This event will delete a registered contact. ## Example input: ```javascript -DeleteContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA") +DeleteContact( + 'did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA', +); ``` ## Example response: @@ -162,7 +164,9 @@ This event will add a new contact. ## Example input: ```javascript -AddContact("did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA") +AddContact( + 'did:peer:2.Ez6LSiopL5aJjRbTu8ZB8uinhodhP7GiSix9DFG5rr2Xp93mg.Vz6MkrnJCtTmSuhoVXUSS8CxZkesWuwHaeHbyp7NT3Z3c9ZoA', +); ``` ## Example response: From 4fd8c49b6841f294591d6ab0588dea26fb6057f8 Mon Sep 17 00:00:00 2001 From: hugoib Date: Tue, 19 Nov 2024 13:57:20 +0100 Subject: [PATCH 09/13] fixed MR comments --- docs/service-layer/README.md | 21 ++++----------------- docs/service-layer/other-events.md | 8 +++++--- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/docs/service-layer/README.md b/docs/service-layer/README.md index 93279dd..be3b924 100644 --- a/docs/service-layer/README.md +++ b/docs/service-layer/README.md @@ -3,7 +3,6 @@ This document outlines the communication between the frontend and the service la # Index - [Service layer overview](#Service-Layer-Overview) -- [Event code examples](#Event-Code-examples) - [Alice registers with mediator](#Alice-registers-with-mediator) - [Bob adds contact](#Bob-adds-contact) - [Bob sends a message routed via mediator](#Bob-sends-a-message-routed-via-mediator) @@ -12,7 +11,7 @@ This document outlines the communication between the frontend and the service la # Service layer overview -The service layer aims to organize the services. A service in this context would be the resolution of a credential offer, a request for a credential issuance or an event to interact with the wallet such as the deletion of a credential. +The service layer aims to organize asynchronous methods and events. A service in this context would be the mediator coordination dance, adding a new contact or sending a didcomm message. ![Event Architecture](./event-architecture.png 'Event architecture') @@ -24,20 +23,6 @@ Benefits of this architecture: - **Performance and scalability.** Asynchronicity is at the core of all communication, which means the system can handle requests without waiting for responses. This approach improves the overall performance and scalability of the system. -# Event code examples - -On the service layer side, there is an instantiation of event methods here: - -- [OID4VCIService.ts](https://github.com/adorsys/eudiw-app/blob/86ef72c949f0a7d00011349051fdb8d58d3f22e8/libs/oid4vc/src/lib/OID4VCIService.ts#L24) - -- [OID4VCService.ts](https://github.com/adorsys/eudiw-app/blob/86ef72c949f0a7d00011349051fdb8d58d3f22e8/libs/oid4vc/src/lib/OID4VCService.ts#L10) - -- [OID4VPService.ts](https://github.com/adorsys/eudiw-app/blob/86ef72c949f0a7d00011349051fdb8d58d3f22e8/libs/oid4vc/src/lib/OID4VPService.ts#L14) - -On the front end layer, an example interacting with the method: OID4VCIService.retrieveCredentialHeaders() can be found here: - -- [Credentials.tsx](https://github.com/adorsys/eudiw-app/blob/86ef72c949f0a7d00011349051fdb8d58d3f22e8/apps/wallet-react/src/pages/credentials/Credentials.tsx#L29) - # Alice registers with mediator This flow currently starts with the scan of a QR code and it is composed of one call: @@ -161,7 +146,9 @@ Real-Time Experience: If you want to add real-time message notifications, a comb ### Example input: -This method receives no input. +```javascript +ReceiveMessages(); +``` ### Example response: diff --git a/docs/service-layer/other-events.md b/docs/service-layer/other-events.md index 5f0f0ba..576cf2e 100644 --- a/docs/service-layer/other-events.md +++ b/docs/service-layer/other-events.md @@ -21,7 +21,9 @@ if (cachedMessages.length > maxMessages) { ## Example input: -This method receives no input. +```javascript +RetrieveMessages(); +``` ## Example response: @@ -64,8 +66,8 @@ This event will delete specific messages. ## Example input: ```javascript -DeleteMessages(did, id); -DeleteMessages('did:peer', 3); +DeleteMessages(messageId); +DeleteMessages(3); ``` ## Example response: From 06a2964416d6d78acd5803c48f3dc36d8a45305c Mon Sep 17 00:00:00 2001 From: hugoib Date: Tue, 26 Nov 2024 12:14:30 +0100 Subject: [PATCH 10/13] improved message retrieval --- docs/service-layer/other-events.md | 119 ++++++++++++++++++++++++++--- 1 file changed, 108 insertions(+), 11 deletions(-) diff --git a/docs/service-layer/other-events.md b/docs/service-layer/other-events.md index 576cf2e..07c66fd 100644 --- a/docs/service-layer/other-events.md +++ b/docs/service-layer/other-events.md @@ -1,6 +1,6 @@ # Index -- [Retrieve New Messages](#Retrieve-Messages) +- [Retrieve Messages](#Retrieve-Messages) - [Delete Messages](#Delete-Messages) - [Retrieve DID](#Retrieve-DID) - [Delete Contact](#Delete-Contact) @@ -8,24 +8,72 @@ # Retrieve New Messages -This event will bring new messages to the FE, which will be stored in the local storage. There will be a limit on cached messages. The limit will be per conversation. Once there are new messages that exceed the pile, we will delete old ones. +The retrieval of messages has the following calls: -## Example logic +1) Initial Sync (or Cache Miss Detection and Full Sync) +2) Periodic Retrieve (Incremental Sync) +3) User Scrolls Up - Polling (On-Demand Fetching for Older Messages) + +Description.- Messages on the frontend will have a pile structure based on dates. Meaning, the frontend will keep the latest messages and will drop older ones. Call number 1 will populate this pile. This call will be called when the app is initialized or if errors are detected. Imagine this pile populates the messages view of a messaging app. + +Call number 2 will bring new messages to the previously mentioned pile. + +Call number 3 will bring a paginated set of messages for older conversations. The user will select a specific conversation and this call will be triggered to request older messages. + +This approach aims to reduce the calls load yet providing a consistent and lightway approach to handle messages communication between the FE and BE. + +## Initial Sync (or Cache Miss Detection and Full Sync) + +### Example input: ```javascript -if (cachedMessages.length > maxMessages) { - const prunedMessages = cachedMessages.slice(-maxMessages); - localStorage.setItem(key, JSON.stringify(prunedMessages)); +RetrieveMessagesInitial(); +``` + +### Example response: + +```json +{ + "status": "success", + "payload": [ + { + "did": "did:peer(..)", + "contact": "Alice", + "message": {"Hey Peter, bring bread."}, + "id": 3 + }, + { + "did": "did:peer(..)", + "contact": "Bob", + "message": {"Hey Bob, bring butter."}, + "id": 2 + }, + { + "did": "did:peer(..)", + "contact": "Hugo", + "message": {"Hey Jan, bring Salt."}, + "id": 1 + } + ] } ``` -## Example input: +### Event channel name: +```bash +RetrieveMessagesInitial +``` + +## Periodic Retrieve (Incremental Sync) + +This event will retrieve new messages that recently came from the mediator. + +### Example input: ```javascript -RetrieveMessages(); +RetrieveMessagesPeriodic(since=2024-11-25T12:00:00Z); ``` -## Example response: +### Example response: ```json { @@ -53,10 +101,52 @@ RetrieveMessages(); } ``` -## Event channel name: +### Event channel name: +```bash +RetrieveMessagesPeriodic +``` + +## User Scrolls Up - Polling (On-Demand Fetching for Older Messages) + +This event will retrieve old messages under user demand. + +### Example input: + +```javascript +RetrieveMessagesPaginated(did, date, pollSize); +``` + +### Example response: + +```json +{ + "status": "success", + "payload": [ + { + "did": "did:peer(..)", + "contact": "Alice", + "message": {"Hey Peter, bring bread."}, + "id": 3 + }, + { + "did": "did:peer(..)", + "contact": "Bob", + "message": {"Hey Bob, bring butter."}, + "id": 2 + }, + { + "did": "did:peer(..)", + "contact": "Hugo", + "message": {"Hey Jan, bring Salt."}, + "id": 1 + } + ] +} +``` +### Event channel name: ```bash -RetrieveMessages +RetrieveMessagesPaginated ``` # Delete Messages @@ -65,6 +155,13 @@ This event will delete specific messages. ## Example input: +```javascript +DeleteMessages(did, id); +DeleteMessages('did:peer', 3); +``` + +## Example input: + ```javascript DeleteMessages(messageId); DeleteMessages(3); From 7e8aabeffe39437153ef9a4992d2e4fb8dd8d447 Mon Sep 17 00:00:00 2001 From: hugoib Date: Tue, 26 Nov 2024 12:23:37 +0100 Subject: [PATCH 11/13] improved retrieval of new messages description --- docs/service-layer/other-events.md | 69 ++++++++++++++++++++---------- 1 file changed, 46 insertions(+), 23 deletions(-) diff --git a/docs/service-layer/other-events.md b/docs/service-layer/other-events.md index 07c66fd..cfe0cf0 100644 --- a/docs/service-layer/other-events.md +++ b/docs/service-layer/other-events.md @@ -14,13 +14,15 @@ The retrieval of messages has the following calls: 2) Periodic Retrieve (Incremental Sync) 3) User Scrolls Up - Polling (On-Demand Fetching for Older Messages) -Description.- Messages on the frontend will have a pile structure based on dates. Meaning, the frontend will keep the latest messages and will drop older ones. Call number 1 will populate this pile. This call will be called when the app is initialized or if errors are detected. Imagine this pile populates the messages view of a messaging app. +Messages on the frontend will have a pile structure based on dates. Meaning, the frontend will keep the latest messages and will drop older ones. Call number 1 will populate this pile. This call will be called when the app is initialized or if errors are detected. Imagine this pile populates the messages view of a messaging app. Call number 2 will bring new messages to the previously mentioned pile. Call number 3 will bring a paginated set of messages for older conversations. The user will select a specific conversation and this call will be triggered to request older messages. -This approach aims to reduce the calls load yet providing a consistent and lightway approach to handle messages communication between the FE and BE. +This approach aims to reduce the calls load yet providing a consistent and lightweight approach to handle messages communication between the FE and BE. + +The pile will have a specific configurable cache size criteria based on amount of messages and dates (e.g., the last N messages, messages within the past X days, etc.). ## Initial Sync (or Cache Miss Detection and Full Sync) @@ -40,24 +42,28 @@ RetrieveMessagesInitial(); "did": "did:peer(..)", "contact": "Alice", "message": {"Hey Peter, bring bread."}, - "id": 3 + "id": 3, + "timestamp": "2024-11-19T23:50:00Z" }, { "did": "did:peer(..)", "contact": "Bob", "message": {"Hey Bob, bring butter."}, - "id": 2 + "id": 2, + "timestamp": "2024-11-19T23:50:00Z" }, { "did": "did:peer(..)", "contact": "Hugo", "message": {"Hey Jan, bring Salt."}, - "id": 1 + "id": 1, + "timestamp": "2024-11-19T23:50:00Z" } ] } ``` + ### Event channel name: ```bash RetrieveMessagesInitial @@ -70,7 +76,7 @@ This event will retrieve new messages that recently came from the mediator. ### Example input: ```javascript -RetrieveMessagesPeriodic(since=2024-11-25T12:00:00Z); +RetrieveMessagesPeriodic(date="2024-11-20T00:00:00Z"); ``` ### Example response: @@ -83,24 +89,35 @@ RetrieveMessagesPeriodic(since=2024-11-25T12:00:00Z); "did": "did:peer(..)", "contact": "Alice", "message": {"Hey Peter, bring bread."}, - "id": 3 + "id": 3, + "timestamp": "2024-11-19T23:50:00Z" }, { "did": "did:peer(..)", "contact": "Bob", "message": {"Hey Bob, bring butter."}, - "id": 2 + "id": 2, + "timestamp": "2024-11-19T23:50:00Z" }, { "did": "did:peer(..)", "contact": "Hugo", "message": {"Hey Jan, bring Salt."}, - "id": 1 + "id": 1, + "timestamp": "2024-11-19T23:50:00Z" } ] } ``` +```json +{ + "status": "error", + "error": "No messages to retrieve" +} + +``` + ### Event channel name: ```bash RetrieveMessagesPeriodic @@ -113,7 +130,8 @@ This event will retrieve old messages under user demand. ### Example input: ```javascript -RetrieveMessagesPaginated(did, date, pollSize); +RetrieveMessagesPaginated(did="did:peer:12345", date="2024-11-20T00:00:00Z", pollSize=50); + ``` ### Example response: @@ -123,25 +141,30 @@ RetrieveMessagesPaginated(did, date, pollSize); "status": "success", "payload": [ { - "did": "did:peer(..)", + "did": "did:peer:12345", "contact": "Alice", - "message": {"Hey Peter, bring bread."}, - "id": 3 + "message": "Do you need anything else?", + "id": 45, + "timestamp": "2024-11-19T23:55:00Z" }, { - "did": "did:peer(..)", - "contact": "Bob", - "message": {"Hey Bob, bring butter."}, - "id": 2 - }, - { - "did": "did:peer(..)", - "contact": "Hugo", - "message": {"Hey Jan, bring Salt."}, - "id": 1 + "did": "did:peer:12345", + "contact": "Alice", + "message":"Don’t forget the bread!", + "id": 44, + "timestamp": "2024-11-19T23:50:00Z" } ] } + +``` + +```json +{ + "status": "error", + "error": "Conversation not found" +} + ``` ### Event channel name: From 48edfb9a63f133871e37b54bcdd7c2d8d7b5b903 Mon Sep 17 00:00:00 2001 From: hugoib Date: Tue, 26 Nov 2024 12:25:19 +0100 Subject: [PATCH 12/13] improved text errors --- docs/service-layer/other-events.md | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/docs/service-layer/other-events.md b/docs/service-layer/other-events.md index cfe0cf0..f08baa5 100644 --- a/docs/service-layer/other-events.md +++ b/docs/service-layer/other-events.md @@ -6,7 +6,7 @@ - [Delete Contact](#Delete-Contact) - [Register Contact](#Register-Contact) -# Retrieve New Messages +# Retrieve Messages The retrieval of messages has the following calls: @@ -178,13 +178,6 @@ This event will delete specific messages. ## Example input: -```javascript -DeleteMessages(did, id); -DeleteMessages('did:peer', 3); -``` - -## Example input: - ```javascript DeleteMessages(messageId); DeleteMessages(3); From f2ac93471a6ced302d2515c4c59e818d25fc1256 Mon Sep 17 00:00:00 2001 From: hugoib Date: Tue, 26 Nov 2024 13:08:48 +0100 Subject: [PATCH 13/13] fixed format issues --- docs/service-layer/other-events.md | 32 ++++++++++++++++-------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/service-layer/other-events.md b/docs/service-layer/other-events.md index f08baa5..8fa40bd 100644 --- a/docs/service-layer/other-events.md +++ b/docs/service-layer/other-events.md @@ -10,17 +10,17 @@ The retrieval of messages has the following calls: -1) Initial Sync (or Cache Miss Detection and Full Sync) -2) Periodic Retrieve (Incremental Sync) -3) User Scrolls Up - Polling (On-Demand Fetching for Older Messages) +1. Initial Sync (or Cache Miss Detection and Full Sync) +2. Periodic Retrieve (Incremental Sync) +3. User Scrolls Up - Polling (On-Demand Fetching for Older Messages) Messages on the frontend will have a pile structure based on dates. Meaning, the frontend will keep the latest messages and will drop older ones. Call number 1 will populate this pile. This call will be called when the app is initialized or if errors are detected. Imagine this pile populates the messages view of a messaging app. -Call number 2 will bring new messages to the previously mentioned pile. +Call number 2 will bring new messages to the previously mentioned pile. -Call number 3 will bring a paginated set of messages for older conversations. The user will select a specific conversation and this call will be triggered to request older messages. +Call number 3 will bring a paginated set of messages for older conversations. The user will select a specific conversation and this call will be triggered to request older messages. -This approach aims to reduce the calls load yet providing a consistent and lightweight approach to handle messages communication between the FE and BE. +This approach aims to reduce the calls load yet providing a consistent and lightweight approach to handle messages communication between the FE and BE. The pile will have a specific configurable cache size criteria based on amount of messages and dates (e.g., the last N messages, messages within the past X days, etc.). @@ -63,20 +63,20 @@ RetrieveMessagesInitial(); } ``` - ### Event channel name: + ```bash RetrieveMessagesInitial ``` ## Periodic Retrieve (Incremental Sync) -This event will retrieve new messages that recently came from the mediator. +This event will retrieve new messages that recently came from the mediator. ### Example input: ```javascript -RetrieveMessagesPeriodic(date="2024-11-20T00:00:00Z"); +RetrieveMessagesPeriodic((date = '2024-11-20T00:00:00Z')); ``` ### Example response: @@ -115,10 +115,10 @@ RetrieveMessagesPeriodic(date="2024-11-20T00:00:00Z"); "status": "error", "error": "No messages to retrieve" } - ``` ### Event channel name: + ```bash RetrieveMessagesPeriodic ``` @@ -130,8 +130,11 @@ This event will retrieve old messages under user demand. ### Example input: ```javascript -RetrieveMessagesPaginated(did="did:peer:12345", date="2024-11-20T00:00:00Z", pollSize=50); - +RetrieveMessagesPaginated( + (did = 'did:peer:12345'), + (date = '2024-11-20T00:00:00Z'), + (pollSize = 50), +); ``` ### Example response: @@ -150,13 +153,12 @@ RetrieveMessagesPaginated(did="did:peer:12345", date="2024-11-20T00:00:00Z", pol { "did": "did:peer:12345", "contact": "Alice", - "message":"Don’t forget the bread!", + "message": "Don’t forget the bread!", "id": 44, "timestamp": "2024-11-19T23:50:00Z" } ] } - ``` ```json @@ -164,10 +166,10 @@ RetrieveMessagesPaginated(did="did:peer:12345", date="2024-11-20T00:00:00Z", pol "status": "error", "error": "Conversation not found" } - ``` ### Event channel name: + ```bash RetrieveMessagesPaginated ```