use `@waku/sdk` (#507)

* u `@bufbuild`

* use `@waku/sdk`

* Create eleven-experts-cough.md
This commit is contained in:
Felicio Mununga 2023-11-10 00:06:41 +01:00 committed by GitHub
parent 23e727b97a
commit 51df6dbb4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 1035 additions and 1240 deletions

View File

@ -0,0 +1,5 @@
---
"@status-im/js": patch
---
use `@waku/sdk`

View File

@ -46,16 +46,19 @@
"clean": "rimraf dist node_modules .turbo"
},
"dependencies": {
"@bufbuild/protobuf": "^1.0.0",
"@bufbuild/protobuf": "1.4.2",
"@libp2p/bootstrap": "^9.0.10",
"@scure/base": "^1.1.1",
"@waku/message-encryption": "^0.0.23",
"@waku/sdk": "^0.0.21",
"ethereum-cryptography": "^1.0.3",
"ethers": "^6.2.1",
"js-waku": "^0.30.0",
"multiformats": "^11.0.1"
},
"devDependencies": {
"@bufbuild/protoc-gen-es": "^1.0.0",
"@bufbuild/protoc-gen-es": "1.4.2",
"@status-im/eslint-config": "*",
"@waku/interfaces": "^0.0.20",
"happy-dom": "^9.1.7"
},
"files": [

View File

@ -1,5 +1,5 @@
import { PageDirection } from 'js-waku'
import { SymDecoder } from 'js-waku/lib/waku_message/version_1'
import { PageDirection } from '@waku/interfaces'
import { createDecoder } from '@waku/message-encryption/symmetric'
import { containsOnlyEmoji } from '../helpers/contains-only-emoji'
import { ApplicationMetadataMessage_Type } from '../protos/application-metadata-message_pb'
@ -207,8 +207,8 @@ export class Chat {
endTime = new Date()
}
await this.client.waku.store.queryOrderedCallback(
[new SymDecoder(this.contentTopic, this.symmetricKey)],
await this.client.waku.store.queryWithOrderedCallback(
[createDecoder(this.contentTopic, this.symmetricKey)],
wakuMessage => {
this.#fetchingMessages = true
this.client.handleWakuMessage(wakuMessage)

View File

@ -2,12 +2,11 @@
* @see https://specs.status.im/spec/1
*/
import { bootstrap } from '@libp2p/bootstrap'
import { Protocols } from '@waku/interfaces'
import { createEncoder } from '@waku/message-encryption/symmetric'
import { createLightNode, waitForRemotePeer } from '@waku/sdk'
import { hexToBytes } from 'ethereum-cryptography/utils'
import { Protocols } from 'js-waku'
import { createLightNode } from 'js-waku/lib/create_waku'
import { PeerDiscoveryStaticPeers } from 'js-waku/lib/peer_discovery_static_list'
import { waitForRemotePeer } from 'js-waku/lib/wait_for_remote_peer'
import { SymEncoder } from 'js-waku/lib/waku_message/version_1'
import { peers } from '../consts/peers'
import { ApplicationMetadataMessage } from '../protos/application-metadata-message_pb'
@ -19,8 +18,8 @@ import { LocalStorage } from './storage'
import type { ApplicationMetadataMessage_Type } from '../protos/application-metadata-message_pb'
import type { Storage } from './storage'
import type { WakuLight } from 'js-waku/lib/interfaces'
import type { MessageV1 as WakuMessage } from 'js-waku/lib/waku_message/version_1'
import type { LightNode } from '@waku/interfaces'
import type { DecodedMessage } from '@waku/message-encryption/symmetric'
const THROWAWAY_ACCOUNT_STORAGE_KEY = 'throwaway_account'
@ -38,7 +37,7 @@ export interface ClientOptions {
}
class Client {
public waku: WakuLight
public waku: LightNode
public readonly wakuMessages: Set<string>
/**
* Tracks open connections which had their streams silently destroyed
@ -64,7 +63,7 @@ class Client {
storage: Storage
constructor(waku: WakuLight, options: ClientOptions) {
constructor(waku: LightNode, options: ClientOptions) {
// Waku
/**
* Waku should be connected and protocols awaited at this point, thus connected.
@ -76,9 +75,9 @@ class Client {
this.#wakuDisconnectionTimer = setInterval(async () => {
const connectionsToClose: Promise<void>[] = []
for (const connection of this.waku.libp2p.connectionManager.getConnections()) {
for (const connection of this.waku.libp2p.getConnections()) {
try {
await this.waku.libp2p.ping(connection.remoteAddr)
await this.waku.libp2p.services.ping.ping(connection.remoteAddr)
if (!this.connected) {
this.connected = true
@ -96,7 +95,7 @@ class Client {
* Note: Assumes 1 remote node and that the diconnection does not require calling
* `waitForRemotePeer` again to ensure protocols/codecs.
*/
this.waku.libp2p.connectionManager.addEventListener('peer:connect', () => {
this.waku.libp2p.addEventListener('peer:connect', () => {
this.connected = true // reconnect
this.emitConnection(this.connected)
@ -105,7 +104,7 @@ class Client {
* >This event will **only** be triggered when the last connection is closed.
* @see https://github.com/libp2p/js-libp2p/blob/bad9e8c0ff58d60a78314077720c82ae331cc55b/doc/API.md?plain=1#L2100
*/
waku.libp2p.connectionManager.addEventListener('peer:disconnect', () => {
waku.libp2p.addEventListener('peer:disconnect', () => {
this.connected = false
this.emitConnection(this.connected)
@ -135,7 +134,7 @@ class Client {
static async start(options: ClientOptions): Promise<Client> {
const { environment = 'production' } = options
let waku: WakuLight | undefined
let waku: LightNode | undefined
let client: Client | undefined
try {
@ -161,7 +160,7 @@ class Client {
* >
* >@see https://forum.vac.dev/t/waku-v2-scalability-studies/142/2
*/
new PeerDiscoveryStaticPeers(peers[environment], { maxPeers: 1 }),
bootstrap({ list: peers[environment] }),
],
},
})
@ -260,17 +259,17 @@ class Client {
payload,
}).toBinary()
await this.waku.lightPush.push(
new SymEncoder(
await this.waku.lightPush.send(
createEncoder({
contentTopic,
symKey,
hexToBytes(this.#account.privateKey)
),
sigPrivKey: hexToBytes(this.#account.privateKey),
}),
{ payload: message }
)
}
public handleWakuMessage = (wakuMessage: WakuMessage): void => {
public handleWakuMessage = (wakuMessage: DecodedMessage): void => {
handleWakuMessage(wakuMessage, this, this.community, this.#account)
}
}

View File

@ -1,5 +1,5 @@
import { createDecoder } from '@waku/message-encryption/symmetric'
import { hexToBytes } from 'ethereum-cryptography/utils'
import { SymDecoder } from 'js-waku/lib/waku_message/version_1'
import { getDifferenceByKeys } from '../../helpers/get-difference-by-keys'
import { getObjectsDifference } from '../../helpers/get-objects-difference'
@ -93,8 +93,8 @@ export class Community {
public fetch = async () => {
// most recent page first
await this.client.waku.store.queryOrderedCallback(
[new SymDecoder(this.contentTopic, this.symmetricKey)],
await this.client.waku.store.queryWithOrderedCallback(
[createDecoder(this.contentTopic, this.symmetricKey)],
wakuMessage => {
this.client.handleWakuMessage(wakuMessage)
@ -109,7 +109,7 @@ export class Community {
private observe = async () => {
await this.client.waku.filter.subscribe(
[new SymDecoder(this.contentTopic, this.symmetricKey)],
[createDecoder(this.contentTopic, this.symmetricKey)],
this.client.handleWakuMessage
)
}
@ -130,7 +130,7 @@ export class Community {
this.chats.set(chatUuid, chat)
const unobserveFn = await this.client.waku.filter.subscribe(
[new SymDecoder(chat.contentTopic, chat.symmetricKey)],
[createDecoder(chat.contentTopic, chat.symmetricKey)],
this.client.handleWakuMessage
)

View File

@ -23,10 +23,10 @@ import { mapChatMessage } from './map-chat-message'
import type { Account } from '../account'
import type { Client } from '../client'
import type { Community } from './community'
import type { MessageV1 as WakuMessage } from 'js-waku/lib/waku_message/version_1'
import type { DecodedMessage } from '@waku/message-encryption/symmetric'
export function handleWakuMessage(
wakuMessage: WakuMessage,
wakuMessage: DecodedMessage,
// state
client: Client,
community: Community,

View File

@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.0.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.4.2 with parameter "target=ts"
// @generated from file application-metadata-message.proto (syntax proto3)
/* eslint-disable */
// @ts-nocheck
@ -43,7 +43,7 @@ export class ApplicationMetadataMessage extends Message<ApplicationMetadataMessa
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'ApplicationMetadataMessage'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'signature', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },

View File

@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.0.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.4.2 with parameter "target=ts"
// @generated from file chat-identity.proto (syntax proto3)
/* eslint-disable */
// @ts-nocheck
@ -84,7 +84,7 @@ export class ChatIdentity extends Message<ChatIdentity> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'ChatIdentity'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },
@ -201,7 +201,7 @@ export class IdentityImage extends Message<IdentityImage> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'IdentityImage'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'payload', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },
@ -312,7 +312,7 @@ export class SocialLink extends Message<SocialLink> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'SocialLink'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'text', kind: 'scalar', T: 9 /* ScalarType.STRING */ },

View File

@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.0.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.4.2 with parameter "target=ts"
// @generated from file chat-message.proto (syntax proto3)
/* eslint-disable */
// @ts-nocheck
@ -33,7 +33,7 @@ export class StickerMessage extends Message<StickerMessage> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'StickerMessage'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'hash', kind: 'scalar', T: 9 /* ScalarType.STRING */ },
@ -88,7 +88,7 @@ export class ImageMessage extends Message<ImageMessage> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'ImageMessage'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'payload', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },
@ -148,7 +148,7 @@ export class AudioMessage extends Message<AudioMessage> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'AudioMessage'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'payload', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },
@ -266,7 +266,7 @@ export class EditMessage extends Message<EditMessage> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'EditMessage'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },
@ -349,7 +349,7 @@ export class DeleteMessage extends Message<DeleteMessage> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'DeleteMessage'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },
@ -510,7 +510,7 @@ export class ChatMessage extends Message<ChatMessage> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'ChatMessage'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },

View File

@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.0.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.4.2 with parameter "target=ts"
// @generated from file communities.proto (syntax proto3)
/* eslint-disable */
// @ts-nocheck
@ -43,7 +43,7 @@ export class Grant extends Message<Grant> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'Grant'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -100,7 +100,7 @@ export class CommunityMember extends Message<CommunityMember> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'CommunityMember'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -199,7 +199,7 @@ export class CommunityPermissions extends Message<CommunityPermissions> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'CommunityPermissions'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'ens_only', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
@ -351,7 +351,7 @@ export class CommunityDescription extends Message<CommunityDescription> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'CommunityDescription'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },
@ -462,7 +462,7 @@ export class CommunityAdminSettings extends Message<CommunityAdminSettings> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'CommunityAdminSettings'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -539,7 +539,7 @@ export class CommunityChat extends Message<CommunityChat> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'CommunityChat'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -613,7 +613,7 @@ export class CommunityCategory extends Message<CommunityCategory> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'CommunityCategory'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -684,7 +684,7 @@ export class CommunityInvitation extends Message<CommunityInvitation> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'CommunityInvitation'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -761,7 +761,7 @@ export class CommunityRequestToJoin extends Message<CommunityRequestToJoin> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'CommunityRequestToJoin'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },
@ -847,7 +847,7 @@ export class CommunityCancelRequestToJoin extends Message<CommunityCancelRequest
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'CommunityCancelRequestToJoin'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },
@ -944,7 +944,7 @@ export class CommunityRequestToJoinResponse extends Message<CommunityRequestToJo
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'CommunityRequestToJoinResponse'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },
@ -1017,7 +1017,7 @@ export class CommunityRequestToLeave extends Message<CommunityRequestToLeave> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'CommunityRequestToLeave'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },
@ -1083,7 +1083,7 @@ export class CommunityMessageArchiveMagnetlink extends Message<CommunityMessageA
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'CommunityMessageArchiveMagnetlink'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },
@ -1172,7 +1172,7 @@ export class WakuMessage extends Message<WakuMessage> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'WakuMessage'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'sig', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },
@ -1247,7 +1247,7 @@ export class WakuMessageArchiveMetadata extends Message<WakuMessageArchiveMetada
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'WakuMessageArchiveMetadata'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'version', kind: 'scalar', T: 13 /* ScalarType.UINT32 */ },
@ -1321,7 +1321,7 @@ export class WakuMessageArchive extends Message<WakuMessageArchive> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'WakuMessageArchive'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'version', kind: 'scalar', T: 13 /* ScalarType.UINT32 */ },
@ -1398,7 +1398,7 @@ export class WakuMessageArchiveIndexMetadata extends Message<WakuMessageArchiveI
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'WakuMessageArchiveIndexMetadata'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'version', kind: 'scalar', T: 13 /* ScalarType.UINT32 */ },
@ -1460,7 +1460,7 @@ export class WakuMessageArchiveIndex extends Message<WakuMessageArchiveIndex> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'WakuMessageArchiveIndex'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{

View File

@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.0.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.4.2 with parameter "target=ts"
// @generated from file emoji-reaction.proto (syntax proto3)
/* eslint-disable */
// @ts-nocheck
@ -73,7 +73,7 @@ export class EmojiReaction extends Message<EmojiReaction> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'EmojiReaction'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },

View File

@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.0.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.4.2 with parameter "target=ts"
// @generated from file enums.proto (syntax proto3)
/* eslint-disable */
// @ts-nocheck

View File

@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.0.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.4.2 with parameter "target=ts"
// @generated from file membership-update-message.proto (syntax proto3)
/* eslint-disable */
// @ts-nocheck
@ -52,7 +52,7 @@ export class MembershipUpdateEvent extends Message<MembershipUpdateEvent> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'MembershipUpdateEvent'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },
@ -211,7 +211,7 @@ export class MembershipUpdateMessage extends Message<MembershipUpdateMessage> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'MembershipUpdateMessage'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'chat_id', kind: 'scalar', T: 9 /* ScalarType.STRING */ },

View File

@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.0.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.4.2 with parameter "target=ts"
// @generated from file pin-message.proto (syntax proto3)
/* eslint-disable */
// @ts-nocheck
@ -50,7 +50,7 @@ export class PinMessage extends Message<PinMessage> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'PinMessage'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },

View File

@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.0.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.4.2 with parameter "target=ts"
// @generated from file protocol-message.proto (syntax proto3)
/* eslint-disable */
// @ts-nocheck
@ -37,7 +37,7 @@ export class SignedPreKey extends Message<SignedPreKey> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'SignedPreKey'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -123,7 +123,7 @@ export class Bundle extends Message<Bundle> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'Bundle'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'identity', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },
@ -190,7 +190,7 @@ export class BundleContainer extends Message<BundleContainer> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'BundleContainer'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'bundle', kind: 'message', T: Bundle },
@ -268,7 +268,7 @@ export class DRHeader extends Message<DRHeader> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'DRHeader'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'key', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },
@ -322,7 +322,7 @@ export class DHHeader extends Message<DHHeader> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'DHHeader'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'key', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },
@ -380,7 +380,7 @@ export class X3DHHeader extends Message<X3DHHeader> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'X3DHHeader'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'key', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },
@ -448,7 +448,7 @@ export class HRHeader extends Message<HRHeader> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'HRHeader'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'key_id', kind: 'scalar', T: 13 /* ScalarType.UINT32 */ },
@ -499,7 +499,7 @@ export class HRKeys extends Message<HRKeys> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'HRKeys'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'keys', kind: 'message', T: HRKey, repeated: true },
@ -553,7 +553,7 @@ export class HRKey extends Message<HRKey> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'HRKey'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'key_id', kind: 'scalar', T: 13 /* ScalarType.UINT32 */ },
@ -627,7 +627,7 @@ export class EncryptedMessageProtocol extends Message<EncryptedMessageProtocol>
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'EncryptedMessageProtocol'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'X3DH_header', kind: 'message', T: X3DHHeader },
@ -712,7 +712,7 @@ export class ProtocolMessage extends Message<ProtocolMessage> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'ProtocolMessage'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{

View File

@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.0.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.4.2 with parameter "target=ts"
// @generated from file push-notifications.proto (syntax proto3)
/* eslint-disable */
// @ts-nocheck
@ -93,7 +93,7 @@ export class PushNotificationRegistration extends Message<PushNotificationRegist
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'PushNotificationRegistration'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -252,7 +252,7 @@ export class PushNotificationRegistrationResponse extends Message<PushNotificati
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'PushNotificationRegistrationResponse'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'success', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
@ -367,7 +367,7 @@ export class ContactCodeAdvertisement extends Message<ContactCodeAdvertisement>
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'ContactCodeAdvertisement'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -429,7 +429,7 @@ export class PushNotificationQuery extends Message<PushNotificationQuery> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'PushNotificationQuery'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -514,7 +514,7 @@ export class PushNotificationQueryInfo extends Message<PushNotificationQueryInfo
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'PushNotificationQueryInfo'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -606,7 +606,7 @@ export class PushNotificationQueryResponse extends Message<PushNotificationQuery
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'PushNotificationQueryResponse'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -702,7 +702,7 @@ export class PushNotification extends Message<PushNotification> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'PushNotification'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -813,7 +813,7 @@ export class PushNotificationRequest extends Message<PushNotificationRequest> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'PushNotificationRequest'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -890,7 +890,7 @@ export class PushNotificationReport extends Message<PushNotificationReport> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'PushNotificationReport'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'success', kind: 'scalar', T: 8 /* ScalarType.BOOL */ },
@ -996,7 +996,7 @@ export class PushNotificationResponse extends Message<PushNotificationResponse>
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'PushNotificationResponse'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'message_id', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },

View File

@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.0.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.4.2 with parameter "target=ts"
// @generated from file status-update.proto (syntax proto3)
/* eslint-disable */
// @ts-nocheck
@ -49,7 +49,7 @@ export class StatusUpdate extends Message<StatusUpdate> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'StatusUpdate'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'clock', kind: 'scalar', T: 4 /* ScalarType.UINT64 */ },

View File

@ -1,4 +1,4 @@
// @generated by protoc-gen-es v1.0.0 with parameter "target=ts"
// @generated by protoc-gen-es v1.4.2 with parameter "target=ts"
// @generated from file url.proto (syntax proto3)
/* eslint-disable */
// @ts-nocheck
@ -47,7 +47,7 @@ export class Community extends Message<Community> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'Community'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -146,7 +146,7 @@ export class Channel extends Message<Channel> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'Channel'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -220,7 +220,7 @@ export class User extends Message<User> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'User'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{
@ -283,7 +283,7 @@ export class URLData extends Message<URLData> {
proto3.util.initPartial(data, this)
}
static readonly runtime = proto3
static readonly runtime: typeof proto3 = proto3
static readonly typeName = 'URLData'
static readonly fields: FieldList = proto3.util.newFieldList(() => [
{ no: 1, name: 'content', kind: 'scalar', T: 12 /* ScalarType.BYTES */ },

View File

@ -1,9 +1,8 @@
import { bootstrap } from '@libp2p/bootstrap'
import { Protocols } from '@waku/interfaces'
import { createDecoder } from '@waku/message-encryption/symmetric'
import { createLightNode, waitForRemotePeer } from '@waku/sdk'
import { bytesToHex } from 'ethereum-cryptography/utils'
import { Protocols } from 'js-waku'
import { createLightNode } from 'js-waku/lib/create_waku'
import { PeerDiscoveryStaticPeers } from 'js-waku/lib/peer_discovery_static_list'
import { waitForRemotePeer } from 'js-waku/lib/wait_for_remote_peer'
import { SymDecoder } from 'js-waku/lib/waku_message/version_1'
import { peers } from '../consts/peers'
import {
@ -26,21 +25,21 @@ import { mapUser } from './map-user'
import type { ChannelInfo } from './map-channel'
import type { CommunityInfo } from './map-community'
import type { UserInfo } from './map-user'
import type { WakuLight } from 'js-waku/lib/interfaces'
import type { MessageV1 as WakuMessage } from 'js-waku/lib/waku_message/version_1'
import type { LightNode } from '@waku/interfaces'
import type { DecodedMessage } from '@waku/message-encryption/symmetric'
export interface RequestClientOptions {
environment?: 'production' | 'test'
}
class RequestClient {
public waku: WakuLight
public waku: LightNode
/** Cache. */
public readonly wakuMessages: Set<string>
private started: boolean
constructor(waku: WakuLight, started = false) {
constructor(waku: LightNode, started = false) {
this.waku = waku
this.wakuMessages = new Set()
this.started = started
@ -49,7 +48,7 @@ class RequestClient {
static async start(options: RequestClientOptions): Promise<RequestClient> {
const { environment = 'production' } = options
let waku: WakuLight | undefined
let waku: LightNode | undefined
let client: RequestClient | undefined
try {
@ -62,9 +61,7 @@ class RequestClient {
pingKeepAlive: 0,
relayKeepAlive: 0,
libp2p: {
peerDiscovery: [
new PeerDiscoveryStaticPeers(peers[environment], { maxPeers: 1 }),
],
peerDiscovery: [bootstrap({ list: peers[environment] })],
},
})
await waku.start()
@ -145,8 +142,8 @@ class RequestClient {
const symmetricKey = await generateKeyFromPassword(publicKey)
let communityDescription: CommunityDescription | undefined = undefined
await this.waku.store.queryOrderedCallback(
[new SymDecoder(contentTopic, symmetricKey)],
await this.waku.store.queryWithOrderedCallback(
[createDecoder(contentTopic, symmetricKey)],
wakuMessage => {
// handle
const message = this.handleWakuMessage(wakuMessage)
@ -202,8 +199,8 @@ class RequestClient {
let contactCodeAdvertisement: ContactCodeAdvertisement | undefined =
undefined
await this.waku.store.queryOrderedCallback(
[new SymDecoder(contentTopic, symmetricKey)],
await this.waku.store.queryWithOrderedCallback(
[createDecoder(contentTopic, symmetricKey)],
wakuMessage => {
// handle
const message = this.handleWakuMessage(wakuMessage)
@ -255,7 +252,7 @@ class RequestClient {
}
private handleWakuMessage = (
wakuMessage: WakuMessage
wakuMessage: DecodedMessage
):
| {
timestamp: Date

View File

@ -0,0 +1,13 @@
diff --git a/node_modules/@libp2p/bootstrap/package.json b/node_modules/@libp2p/bootstrap/package.json
index 11a2f41..d8ae3f8 100644
--- a/node_modules/@libp2p/bootstrap/package.json
+++ b/node_modules/@libp2p/bootstrap/package.json
@@ -24,7 +24,7 @@
],
"exports": {
".": {
- "types": "./src/index.d.ts",
+ "types": "./dist/src/index.d.ts",
"import": "./dist/src/index.js"
}
},

2014
yarn.lock

File diff suppressed because it is too large Load Diff