From e59834e4caa427d96a02da1658c97ac8dfd2900c Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Tue, 13 Dec 2022 15:52:01 +0300 Subject: [PATCH 01/14] Add spec for web3inbox --- docs/specs/meta-clients/web3inbox/README.md | 9 ++ docs/specs/meta-clients/web3inbox/sdk-api.md | 117 +++++++++++++++++++ 2 files changed, 126 insertions(+) create mode 100644 docs/specs/meta-clients/web3inbox/README.md create mode 100644 docs/specs/meta-clients/web3inbox/sdk-api.md diff --git a/docs/specs/meta-clients/web3inbox/README.md b/docs/specs/meta-clients/web3inbox/README.md new file mode 100644 index 000000000..82cff41b4 --- /dev/null +++ b/docs/specs/meta-clients/web3inbox/README.md @@ -0,0 +1,9 @@ +# Web3Inbox SDK + +The Web3Inbox SDK will combine functionality of +[Push](../../clients/push/README.md) and [Chat](../../clients/chat/README.md) +into one offering by giving access to the [Web3Inbox](https://web3inbox.com) +inner state and user interface. + +This will model the inner "W3I proxy" state manager in Web3Inbox.com, +as well the native SDKs that will wrap it for native iOS or android experiences. diff --git a/docs/specs/meta-clients/web3inbox/sdk-api.md b/docs/specs/meta-clients/web3inbox/sdk-api.md new file mode 100644 index 000000000..64e3aca07 --- /dev/null +++ b/docs/specs/meta-clients/web3inbox/sdk-api.md @@ -0,0 +1,117 @@ +# Web3Inbox SDK + +The Web3InboxSDK will encompass both [Push](../../clients/push/README.md) and +[Chat](../../clients/chat/README.md) methods and event listeners. All methods +within the class documented here will be used internally by the web3inbox web +app. Internally, the state will be managed through [RxJS](https://rxjs.dev/), +which will allow the SDK to cleanly listen to events from anywhere. This will of +course the include the Chat & Push clients in the webapp. In the case of the +webapp being integrated in a native webview, RxJS will hook into the `message` +event on the window, receiving messages from the `postMessage` calls. Note, this +will also enable communication with any parent context (React Native, web page +displaying Web3Inbox in an `iframe`, etc) + + +```typescript +abstract class Web3InboxSDK { + + // ---------- Chat Methods (Internal W3I use) ----------------------------------------------- // + + // register a blockchain account with a public key / returns the public key + public abstract register(params: { + account: string; + private?: boolean; + }): Promise; + + // queries the default keyserver with a blockchain account / returns the public key + public abstract resolve(params: { + account: string; + }): Promise; + + // sends a chat invite to peer account / returns an invite id + public abstract invite(params: { + account: string; + invite: Invite; + }): Promise; + + // accepts a chat invite by id / returns thread topic + public abstract accept(params: { + inviteId: number; + }): Promise; + +// rejects a chat invite by id + public abstract reject(params: { + inviteId: string; + }): Promise; + + // sends a chat message to an active chat thread + public abstract message(params: { + topic: string; + message: string; + media?: Media + }): Promise; + + // ping its peer to evaluate if it's currently online + public abstract ping(params: { + topic: string; + }): Promise + + // leaves a chat thread and stops receiving messages + public abstract leave(params: { + topic: string; + }): Promise; + + // adds peer account with public key + public abstract addContact(params: { + account: string; + publicKey: string; + }): Promise + + // returns all invites matching an account / returns maps of invites indexed by id + public abstract getInvites(params: { + account: string; + }): Promise> + + // returns all threads matching an account / returns map of threads indexed by topic + public abstract getThreads(params: { + account: string; + }): Promise>; + + // returns all messages matching a thread's topic / returns array of messages + public abstract getMessages(params: { + topic: string; + }): Promise<[Message]>; + + // request push subscription + public abstract request(params: { account: string, pairingTopic: string }): Promise<{ id }>; + + // send push notification message + public abstract notify(params: { topic: string, message: PushMessage }): Promise + + // query all active subscriptions + public abstract getActiveSubscriptions(): Promise>; + + // delete active subscription + public abstract delete(params: { topic: string }): Promise; + + // ---------- Events ----------------------------------------------- // + // Although the listeners are available, the intended use is to get + // events through RxJS observers + + // subscribe to new chat invites received + public abstract on("chat_invite", ({ id: number, invite: Invite }) => {}): void; + + // subscribe to new chat thread joined + public abstract on("chat_joined", ({ topic: string }) => {}): void; + + // subscribe to new chat messages received + public abstract on("chat_message", ({ topic: string, payload: Message }) => {}): void; + + // subscribe to new chat thread left + public abstract on("chat_left", ({ topic: string }) => {}): void; + + // subscribe to push response + public abstract on("push_response", (id: number, response: { error?: Reason, subscription?: PushSubscription }) => {}): void; +} +``` + From 17c2a550d5e846667ae8098c1fc8ae9831ce6f7f Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Tue, 13 Dec 2022 16:06:39 +0300 Subject: [PATCH 02/14] Add init function --- docs/specs/meta-clients/web3inbox/sdk-api.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/specs/meta-clients/web3inbox/sdk-api.md b/docs/specs/meta-clients/web3inbox/sdk-api.md index 64e3aca07..8cd0f630f 100644 --- a/docs/specs/meta-clients/web3inbox/sdk-api.md +++ b/docs/specs/meta-clients/web3inbox/sdk-api.md @@ -15,6 +15,14 @@ displaying Web3Inbox in an `iframe`, etc) ```typescript abstract class Web3InboxSDK { + // If the init function does not receive `params`, Web3InboxSDK operates in a + // stateless manner where it does not maintain chat/push clients and only + // listens to external events. + public static abstract init(params?: { + relayUrl: string; + projectId: string; + }): Promise + // ---------- Chat Methods (Internal W3I use) ----------------------------------------------- // // register a blockchain account with a public key / returns the public key @@ -39,7 +47,7 @@ abstract class Web3InboxSDK { inviteId: number; }): Promise; -// rejects a chat invite by id + // rejects a chat invite by id public abstract reject(params: { inviteId: string; }): Promise; @@ -82,6 +90,9 @@ abstract class Web3InboxSDK { topic: string; }): Promise<[Message]>; + + // ---------- Push Methods (Internal W3I use) ----------------------------------------------- // + // request push subscription public abstract request(params: { account: string, pairingTopic: string }): Promise<{ id }>; From 41806745098bcb0d0cb758a7b067f8af935baa41 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Tue, 13 Dec 2022 16:17:18 +0300 Subject: [PATCH 03/14] Add spec to sidebar --- docs/specs/meta-clients/web3inbox/README.md | 2 +- docs/specs/meta-clients/web3inbox/sdk-api.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/specs/meta-clients/web3inbox/README.md b/docs/specs/meta-clients/web3inbox/README.md index 82cff41b4..3c5e92b99 100644 --- a/docs/specs/meta-clients/web3inbox/README.md +++ b/docs/specs/meta-clients/web3inbox/README.md @@ -1,4 +1,4 @@ -# Web3Inbox SDK +# Web3Inbox SDK Overview The Web3Inbox SDK will combine functionality of [Push](../../clients/push/README.md) and [Chat](../../clients/chat/README.md) diff --git a/docs/specs/meta-clients/web3inbox/sdk-api.md b/docs/specs/meta-clients/web3inbox/sdk-api.md index 8cd0f630f..9def707ad 100644 --- a/docs/specs/meta-clients/web3inbox/sdk-api.md +++ b/docs/specs/meta-clients/web3inbox/sdk-api.md @@ -1,4 +1,4 @@ -# Web3Inbox SDK +# Web3Inbox SDK API The Web3InboxSDK will encompass both [Push](../../clients/push/README.md) and [Chat](../../clients/chat/README.md) methods and event listeners. All methods From a1e12eb0be1b135ade50774c2c62d8a123653251 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Tue, 13 Dec 2022 16:34:25 +0300 Subject: [PATCH 04/14] Add sidebar --- sidebars.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sidebars.js b/sidebars.js index c0306d0bc..5e964450a 100644 --- a/sidebars.js +++ b/sidebars.js @@ -129,6 +129,22 @@ module.exports = { }, ], }, + { + type: "category", + label: "Meta-Clients API", + items: [ + { + type: "category", + label: "Web3Inbox", + items: [ + { + type: "autogenerated", + dirName: "specs/meta-clients/web3inbox", + } + ], + }, + ], + }, { type: "category", label: "Server APIs", From 29fefc25ffa0c37b4cb7dbfab4453cb0ad2a759c Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Wed, 14 Dec 2022 10:31:23 +0300 Subject: [PATCH 05/14] Update docs/specs/meta-clients/web3inbox/README.md Co-authored-by: Ben Kremer --- docs/specs/meta-clients/web3inbox/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/specs/meta-clients/web3inbox/README.md b/docs/specs/meta-clients/web3inbox/README.md index 3c5e92b99..7963daf9c 100644 --- a/docs/specs/meta-clients/web3inbox/README.md +++ b/docs/specs/meta-clients/web3inbox/README.md @@ -5,5 +5,5 @@ The Web3Inbox SDK will combine functionality of into one offering by giving access to the [Web3Inbox](https://web3inbox.com) inner state and user interface. -This will model the inner "W3I proxy" state manager in Web3Inbox.com, +This spec aims to model the inner "W3I proxy" state manager in Web3Inbox.com, as well the native SDKs that will wrap it for native iOS or android experiences. From 497e1241ce2cb72daffa25fa3b5a7a4a890690b2 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Wed, 14 Dec 2022 10:51:12 +0300 Subject: [PATCH 06/14] Dictate that observers will replace event listeners --- .../meta-clients/web3inbox/data-structures.md | 8 ++ docs/specs/meta-clients/web3inbox/sdk-api.md | 76 ++++++++++--------- 2 files changed, 50 insertions(+), 34 deletions(-) create mode 100644 docs/specs/meta-clients/web3inbox/data-structures.md diff --git a/docs/specs/meta-clients/web3inbox/data-structures.md b/docs/specs/meta-clients/web3inbox/data-structures.md new file mode 100644 index 000000000..b012efeb4 --- /dev/null +++ b/docs/specs/meta-clients/web3inbox/data-structures.md @@ -0,0 +1,8 @@ +```typescript +// Read more: https://rxjs.dev/guide/observer +interface Observer { + next: (val: TObservedValue) => void + error: (error: Error) => void + complete: () => void +} +``` diff --git a/docs/specs/meta-clients/web3inbox/sdk-api.md b/docs/specs/meta-clients/web3inbox/sdk-api.md index 9def707ad..d62d2382f 100644 --- a/docs/specs/meta-clients/web3inbox/sdk-api.md +++ b/docs/specs/meta-clients/web3inbox/sdk-api.md @@ -1,30 +1,24 @@ # Web3Inbox SDK API The Web3InboxSDK will encompass both [Push](../../clients/push/README.md) and -[Chat](../../clients/chat/README.md) methods and event listeners. All methods +[Chat](../../clients/chat/README.md) methods and event listeners. All methods within the class documented here will be used internally by the web3inbox web -app. Internally, the state will be managed through [RxJS](https://rxjs.dev/), +app. Internally, the state will be managed through [RxJS](https://rxjs.dev/), which will allow the SDK to cleanly listen to events from anywhere. This will of -course the include the Chat & Push clients in the webapp. In the case of the -webapp being integrated in a native webview, RxJS will hook into the `message` -event on the window, receiving messages from the `postMessage` calls. Note, this -will also enable communication with any parent context (React Native, web page -displaying Web3Inbox in an `iframe`, etc) +course the include the Chat & Push clients in the webapp. +## Stateless Mode +In the case of the webapp being integrated in a native webview, RxJS will hook +into the `message` event on the window, receiving messages from the +`postMessage` calls. Note, this will also enable communication with any parent +context (React Native, web page displaying Web3Inbox in an `iframe`, etc). + +This is Web3InboxSDK's stateless mode, where it won't manage any clients and +will instead just be relaying info to the embedded Web3Inbox user interface. ```typescript -abstract class Web3InboxSDK { - // If the init function does not receive `params`, Web3InboxSDK operates in a - // stateless manner where it does not maintain chat/push clients and only - // listens to external events. - public static abstract init(params?: { - relayUrl: string; - projectId: string; - }): Promise - - // ---------- Chat Methods (Internal W3I use) ----------------------------------------------- // - +abstract class Web3InboxSDKChatFacade { // register a blockchain account with a public key / returns the public key public abstract register(params: { account: string; @@ -90,9 +84,22 @@ abstract class Web3InboxSDK { topic: string; }): Promise<[Message]>; + // subscribe to new chat invites received + public abstract observe("chat_invite", Observer<{ id: number, invite: Invite }>): void; + + // subscribe to new chat thread joined + public abstract observe("chat_joined", Observer<{ topic: string }>): void; + + // subscribe to new chat messages received + public abstract observe("chat_message", Observer<{ topic: string, payload: Message}>): void; + + // subscribe to new chat thread left + public abstract observe("chat_left", Observer<{ topic: string }>): void; + - // ---------- Push Methods (Internal W3I use) ----------------------------------------------- // - +} + +abstract class Web3InboxSDKPushFacade { // request push subscription public abstract request(params: { account: string, pairingTopic: string }): Promise<{ id }>; @@ -105,24 +112,25 @@ abstract class Web3InboxSDK { // delete active subscription public abstract delete(params: { topic: string }): Promise; - // ---------- Events ----------------------------------------------- // - // Although the listeners are available, the intended use is to get - // events through RxJS observers - - // subscribe to new chat invites received - public abstract on("chat_invite", ({ id: number, invite: Invite }) => {}): void; + public abstract observe("push_response", Observer<{id: number, response: {error?: Reason, subscription?: PushSubscription }>): void; +} - // subscribe to new chat thread joined - public abstract on("chat_joined", ({ topic: string }) => {}): void; +abstract class Web3InboxSDK { - // subscribe to new chat messages received - public abstract on("chat_message", ({ topic: string, payload: Message }) => {}): void; + // Note that the facade objects are not the actual clients, but a layer on top + // of them, this is so that their functionality and state can be managed + // within web3inbox. + public readonly get chat: Web3InboxSDKChatFacade + public readonly get push: Web3InboxSDKPushFacade - // subscribe to new chat thread left - public abstract on("chat_left", ({ topic: string }) => {}): void; + // If the init function does not receive `params`, Web3InboxSDK operates in a + // stateless manner where it does not maintain chat/push clients and only + // listens to external events. + public static abstract init(params?: { + relayUrl: string; + projectId: string; + }): Promise - // subscribe to push response - public abstract on("push_response", (id: number, response: { error?: Reason, subscription?: PushSubscription }) => {}): void; } ``` From 64f08e17d55d41ab52777f989c0a464271eb4ace Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Wed, 14 Dec 2022 10:52:22 +0300 Subject: [PATCH 07/14] Make error and complete optional in observer --- docs/specs/meta-clients/web3inbox/data-structures.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/specs/meta-clients/web3inbox/data-structures.md b/docs/specs/meta-clients/web3inbox/data-structures.md index b012efeb4..281e5616f 100644 --- a/docs/specs/meta-clients/web3inbox/data-structures.md +++ b/docs/specs/meta-clients/web3inbox/data-structures.md @@ -2,7 +2,7 @@ // Read more: https://rxjs.dev/guide/observer interface Observer { next: (val: TObservedValue) => void - error: (error: Error) => void - complete: () => void + error?: (error: Error) => void + complete?: () => void } ``` From 179e57c1a1ceef0bca9f71a6f193b6a16c053cac Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Wed, 14 Dec 2022 16:45:49 +0300 Subject: [PATCH 08/14] Clarify unobservers --- docs/specs/meta-clients/web3inbox/sdk-api.md | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/specs/meta-clients/web3inbox/sdk-api.md b/docs/specs/meta-clients/web3inbox/sdk-api.md index d62d2382f..fcb1216bb 100644 --- a/docs/specs/meta-clients/web3inbox/sdk-api.md +++ b/docs/specs/meta-clients/web3inbox/sdk-api.md @@ -84,18 +84,21 @@ abstract class Web3InboxSDKChatFacade { topic: string; }): Promise<[Message]>; + /* + Event observing. + Note: All observers return a method to stop observing. + */ // subscribe to new chat invites received - public abstract observe("chat_invite", Observer<{ id: number, invite: Invite }>): void; + public abstract observe("chat_invite", Observer<{ id: number, invite: Invite}>): () => void; // subscribe to new chat thread joined - public abstract observe("chat_joined", Observer<{ topic: string }>): void; + public abstract observe("chat_joined", Observer<{ topic: string }>): () => void; // subscribe to new chat messages received - public abstract observe("chat_message", Observer<{ topic: string, payload: Message}>): void; + public abstract observe("chat_message", Observer<{ topic: string, payload: Message}>): () => void; // subscribe to new chat thread left - public abstract observe("chat_left", Observer<{ topic: string }>): void; - + public abstract observe("chat_left", Observer<{ topic: string }>): () => void; } @@ -112,7 +115,11 @@ abstract class Web3InboxSDKPushFacade { // delete active subscription public abstract delete(params: { topic: string }): Promise; - public abstract observe("push_response", Observer<{id: number, response: {error?: Reason, subscription?: PushSubscription }>): void; + /* + Event observing. + Note: All observers return a method to stop observing. + */ + public abstract observe("push_response", Observer<{id: number, response:{error?: Reason, subscription?: PushSubscription }>): () => void; } abstract class Web3InboxSDK { From 696d5fdb0940ccac5982aa65fb65c291b866ec97 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Thu, 15 Dec 2022 11:52:11 +0300 Subject: [PATCH 09/14] Add castUrl to supplement push client --- docs/specs/meta-clients/web3inbox/sdk-api.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/specs/meta-clients/web3inbox/sdk-api.md b/docs/specs/meta-clients/web3inbox/sdk-api.md index fcb1216bb..4c5d5f76b 100644 --- a/docs/specs/meta-clients/web3inbox/sdk-api.md +++ b/docs/specs/meta-clients/web3inbox/sdk-api.md @@ -136,6 +136,7 @@ abstract class Web3InboxSDK { public static abstract init(params?: { relayUrl: string; projectId: string; + castUrl?: string; }): Promise } From 2526ab75308f0a84566b2cc4b69298878ddb02e8 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Thu, 15 Dec 2022 13:49:23 +0300 Subject: [PATCH 10/14] Document stateless communication --- .../web3inbox/stateless-communication.md | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 docs/specs/meta-clients/web3inbox/stateless-communication.md diff --git a/docs/specs/meta-clients/web3inbox/stateless-communication.md b/docs/specs/meta-clients/web3inbox/stateless-communication.md new file mode 100644 index 000000000..2c2fde6ef --- /dev/null +++ b/docs/specs/meta-clients/web3inbox/stateless-communication.md @@ -0,0 +1,21 @@ +# Stateless Communication + +In the case of stateless mode, the parent (Eg: native app displaying a webview) +will communicate using `postMessage`, sending messages one-way to the client. + +The message format should be as follows: + +```typescript +class EventMessage { + eventName: string + eventData: Object + type: 'chat' | 'push' +} +``` + +Where `eventName` is 1:1 original event name from the original clients since +they are already prefixed. Eg: `chat_message`. `eventData` is the unencrypted +event data coming from the original client. Eg: `Message` coming from +`chat_message` event. + +`type` is the name of the client the event is coming from. From bbbb1e338a2a9699b2fdb0e0202231eadf848246 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Thu, 15 Dec 2022 13:51:12 +0300 Subject: [PATCH 11/14] Update docs/specs/meta-clients/web3inbox/README.md Co-authored-by: Bartosz Rozwarski --- docs/specs/meta-clients/web3inbox/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/specs/meta-clients/web3inbox/README.md b/docs/specs/meta-clients/web3inbox/README.md index 7963daf9c..5cb006f18 100644 --- a/docs/specs/meta-clients/web3inbox/README.md +++ b/docs/specs/meta-clients/web3inbox/README.md @@ -1,6 +1,6 @@ # Web3Inbox SDK Overview -The Web3Inbox SDK will combine functionality of +The Web3Inbox SDK combines functionality of [Push](../../clients/push/README.md) and [Chat](../../clients/chat/README.md) into one offering by giving access to the [Web3Inbox](https://web3inbox.com) inner state and user interface. From b79ca6c000c1c1122d35d8daf37a77109cb0501b Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Thu, 15 Dec 2022 13:56:43 +0300 Subject: [PATCH 12/14] Update inviteId to be number --- docs/specs/meta-clients/web3inbox/sdk-api.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/specs/meta-clients/web3inbox/sdk-api.md b/docs/specs/meta-clients/web3inbox/sdk-api.md index 4c5d5f76b..8d4e6c428 100644 --- a/docs/specs/meta-clients/web3inbox/sdk-api.md +++ b/docs/specs/meta-clients/web3inbox/sdk-api.md @@ -43,7 +43,7 @@ abstract class Web3InboxSDKChatFacade { // rejects a chat invite by id public abstract reject(params: { - inviteId: string; + inviteId: number; }): Promise; // sends a chat message to an active chat thread From 2929136c93a7af40a50e53a9fc32257251e389f0 Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Thu, 15 Dec 2022 15:25:24 +0300 Subject: [PATCH 13/14] Update format to use json rpc --- .../web3inbox/stateless-communication.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/docs/specs/meta-clients/web3inbox/stateless-communication.md b/docs/specs/meta-clients/web3inbox/stateless-communication.md index 2c2fde6ef..cd117d145 100644 --- a/docs/specs/meta-clients/web3inbox/stateless-communication.md +++ b/docs/specs/meta-clients/web3inbox/stateless-communication.md @@ -3,19 +3,18 @@ In the case of stateless mode, the parent (Eg: native app displaying a webview) will communicate using `postMessage`, sending messages one-way to the client. -The message format should be as follows: +The message format should be as follows, following JSON RPC: ```typescript class EventMessage { - eventName: string - eventData: Object - type: 'chat' | 'push' + jsonrpc: "2.0", + method: string // eventName + params: object // eventData + id: number } ``` -Where `eventName` is 1:1 original event name from the original clients since -they are already prefixed. Eg: `chat_message`. `eventData` is the unencrypted +Where `method`/`eventName` is 1:1 original event name from the original clients since +they are already prefixed. Eg: `chat_message`. `params`/`eventData` is the unencrypted event data coming from the original client. Eg: `Message` coming from `chat_message` event. - -`type` is the name of the client the event is coming from. From 2ee7c0a625c6a16af28fff38093615c8a1c20eff Mon Sep 17 00:00:00 2001 From: Celine Sarafa Date: Thu, 15 Dec 2022 16:02:26 +0300 Subject: [PATCH 14/14] Use present tense --- docs/specs/meta-clients/web3inbox/sdk-api.md | 14 +++++++------- .../web3inbox/stateless-communication.md | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/specs/meta-clients/web3inbox/sdk-api.md b/docs/specs/meta-clients/web3inbox/sdk-api.md index 8d4e6c428..48ddc2531 100644 --- a/docs/specs/meta-clients/web3inbox/sdk-api.md +++ b/docs/specs/meta-clients/web3inbox/sdk-api.md @@ -1,16 +1,16 @@ # Web3Inbox SDK API -The Web3InboxSDK will encompass both [Push](../../clients/push/README.md) and +The Web3InboxSDK encompasses both [Push](../../clients/push/README.md) and [Chat](../../clients/chat/README.md) methods and event listeners. All methods -within the class documented here will be used internally by the web3inbox web -app. Internally, the state will be managed through [RxJS](https://rxjs.dev/), -which will allow the SDK to cleanly listen to events from anywhere. This will of -course the include the Chat & Push clients in the webapp. +within the class documented here are used internally by the web3inbox web +app. Internally, the state is managed through [RxJS](https://rxjs.dev/), +which allows the SDK to cleanly listen to events from anywhere. This of +course includes the Chat & Push clients in the webapp. ## Stateless Mode -In the case of the webapp being integrated in a native webview, RxJS will hook +In the case of the webapp being integrated in a native webview, RxJS hooks into the `message` event on the window, receiving messages from the -`postMessage` calls. Note, this will also enable communication with any parent +`postMessage` calls. Note, this also enables communication with any parent context (React Native, web page displaying Web3Inbox in an `iframe`, etc). This is Web3InboxSDK's stateless mode, where it won't manage any clients and diff --git a/docs/specs/meta-clients/web3inbox/stateless-communication.md b/docs/specs/meta-clients/web3inbox/stateless-communication.md index cd117d145..f3db6096d 100644 --- a/docs/specs/meta-clients/web3inbox/stateless-communication.md +++ b/docs/specs/meta-clients/web3inbox/stateless-communication.md @@ -1,7 +1,7 @@ # Stateless Communication In the case of stateless mode, the parent (Eg: native app displaying a webview) -will communicate using `postMessage`, sending messages one-way to the client. +communicates using `postMessage`, sending messages one-way to the client. The message format should be as follows, following JSON RPC: