fix test after rebase
This commit is contained in:
parent
6b67c4229f
commit
9227a83810
|
@ -14,8 +14,17 @@
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"module": "dist/index.esm.js",
|
"module": "dist/index.esm.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
|
"targets": {
|
||||||
|
"main": {
|
||||||
|
"includeNodeModules": [
|
||||||
|
"protons-runtime",
|
||||||
|
"uint8arraylist"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prebuild": "rm -rf dist",
|
"prebuild": "rm -rf dist",
|
||||||
|
"dev": "parcel",
|
||||||
"build": "parcel build",
|
"build": "parcel build",
|
||||||
"build:vite": "vite build",
|
"build:vite": "vite build",
|
||||||
"build:types": "tsc --emitDeclarationOnly",
|
"build:types": "tsc --emitDeclarationOnly",
|
||||||
|
@ -37,7 +46,8 @@
|
||||||
"pbkdf2": "^3.1.2",
|
"pbkdf2": "^3.1.2",
|
||||||
"protons-runtime": "^1.0.4",
|
"protons-runtime": "^1.0.4",
|
||||||
"secp256k1": "^4.0.2",
|
"secp256k1": "^4.0.2",
|
||||||
"uuid": "^8.3.2"
|
"uuid": "^8.3.2",
|
||||||
|
"protobufjs": "^6.11.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bn.js": "^5.1.0",
|
"@types/bn.js": "^5.1.0",
|
||||||
|
|
|
@ -117,7 +117,7 @@ export interface CommunityDescription {
|
||||||
members: CommunityMember
|
members: CommunityMember
|
||||||
permissions: CommunityPermissions
|
permissions: CommunityPermissions
|
||||||
identity: ChatIdentity
|
identity: ChatIdentity
|
||||||
chats: CommunityChat
|
chats: Record<string,CommunityChat>
|
||||||
banList: string[]
|
banList: string[]
|
||||||
categories: CommunityCategory
|
categories: CommunityCategory
|
||||||
archiveMagnetlinkClock: bigint
|
archiveMagnetlinkClock: bigint
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import { getPredefinedBootstrapNodes, Waku } from 'js-waku'
|
import { getPredefinedBootstrapNodes, Waku } from 'js-waku'
|
||||||
|
|
||||||
import { ApplicationMetadataMessage } from '~/protos/application-metadata-message'
|
import { ApplicationMetadataMessage } from '../protos/application-metadata-message'
|
||||||
import { ChatMessage } from '~/protos/chat-message'
|
import { ChatMessage } from '../protos/chat-message'
|
||||||
import { CommunityChat, CommunityDescription } from '~/protos/communities'
|
import { CommunityChat, CommunityDescription } from '../protos/communities'
|
||||||
|
|
||||||
import { idToContentTopic } from './contentTopic'
|
import { idToContentTopic } from './contentTopic'
|
||||||
import { createSymKeyFromPassword } from './encryption'
|
import { createSymKeyFromPassword } from './encryption'
|
||||||
|
import { hexToBuf } from './utils'
|
||||||
|
|
||||||
import type { WakuMessage } from 'js-waku'
|
import type { WakuMessage } from 'js-waku'
|
||||||
|
|
||||||
export interface ClientOptions {
|
export interface ClientOptions {
|
||||||
publicKey: string
|
publicKey: string
|
||||||
environement?: 'production' | 'test'
|
env?: 'production' | 'test'
|
||||||
callback: (message: ChatMessage) => void
|
callback: (message: ChatMessage) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,15 +31,21 @@ export class Client {
|
||||||
}
|
}
|
||||||
|
|
||||||
public async start() {
|
public async start() {
|
||||||
|
console.log(getPredefinedBootstrapNodes('test'))
|
||||||
this.waku = await Waku.create(
|
this.waku = await Waku.create(
|
||||||
this.options.environement === 'test'
|
this.options.env === 'test'
|
||||||
? {
|
? {
|
||||||
bootstrap: {
|
bootstrap: {
|
||||||
getPeers: getPredefinedBootstrapNodes('test'),
|
peers: [
|
||||||
|
'/dns4/node-01.gc-us-central1-a.wakuv2.test.statusim.net/tcp/443/wss/p2p/16Uiu2HAmJb2e28qLXxT5kZxVUUoJt72EMzNGXB47Rxx5hw3q4YjS',
|
||||||
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
: { bootstrap: { default: true } }
|
: { bootstrap: { default: true } }
|
||||||
)
|
)
|
||||||
|
|
||||||
|
console.log('here')
|
||||||
|
|
||||||
await this.waku.waitForRemotePeer()
|
await this.waku.waitForRemotePeer()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,7 +106,7 @@ export class Client {
|
||||||
this.waku!.relay.addObserver(this.handleMessage, contentTopics)
|
this.waku!.relay.addObserver(this.handleMessage, contentTopics)
|
||||||
}
|
}
|
||||||
|
|
||||||
private handleMessage = (message: WakuMessage) => {
|
private async handleMessage(message: WakuMessage) {
|
||||||
if (!message.payload || !message.timestamp) {
|
if (!message.payload || !message.timestamp) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -128,6 +134,8 @@ export class Client {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async sendMessage(message: any) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
export const createClient = async (options: ClientOptions) => {
|
export const createClient = async (options: ClientOptions) => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { Waku } from 'js-waku'
|
import { getPredefinedBootstrapNodes, Waku } from 'js-waku'
|
||||||
// import { Fleet } from 'js-waku/build/main/lib/discovery/predefined'
|
|
||||||
|
|
||||||
|
// import { Fleet } from 'js-waku/build/main/lib/discovery/predefined'
|
||||||
// TOOD: params
|
// TOOD: params
|
||||||
// TODO?: reconnect/keep alive
|
// TODO?: reconnect/keep alive
|
||||||
// TODO?: error handling
|
// TODO?: error handling
|
||||||
|
@ -19,6 +19,5 @@ export async function createClient(): Promise<Waku> {
|
||||||
libp2p: { config: { pubsub: { enabled: true, emitSelf: true } } },
|
libp2p: { config: { pubsub: { enabled: true, emitSelf: true } } },
|
||||||
})
|
})
|
||||||
await waku.waitForRemotePeer()
|
await waku.waitForRemotePeer()
|
||||||
|
|
||||||
return waku
|
return waku
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,26 +1,61 @@
|
||||||
export { Chat } from './chat'
|
// export { Chat } from './chat'
|
||||||
export { createClient } from './client'
|
// // export type { Client, ClientOptions } from './client'
|
||||||
export { Community } from './community'
|
// export { createClient } from './client'
|
||||||
export { Contacts } from './contacts'
|
// export { Community } from './community'
|
||||||
export type { GroupChat, GroupChatsType } from './groupChats'
|
// export { Contacts } from './contacts'
|
||||||
export { GroupChats } from './groupChats'
|
// export type { GroupChat, GroupChatsType } from './groupChats'
|
||||||
export { Identity } from './identity'
|
// export { GroupChats } from './groupChats'
|
||||||
export { Messenger } from './messenger'
|
// export { Identity } from './identity'
|
||||||
export {
|
// export { Messenger } from './messenger'
|
||||||
bufToHex,
|
// export {
|
||||||
compressPublicKey,
|
// bufToHex,
|
||||||
genPrivateKeyWithEntropy,
|
// compressPublicKey,
|
||||||
getLatestUserNickname,
|
// genPrivateKeyWithEntropy,
|
||||||
hexToBuf,
|
// getLatestUserNickname,
|
||||||
} from './utils'
|
// hexToBuf,
|
||||||
export { ApplicationMetadataMessage } from './wire/application_metadata_message'
|
// } from './utils'
|
||||||
export type {
|
// export { ApplicationMetadataMessage } from './wire/application_metadata_message'
|
||||||
AudioContent,
|
// export type {
|
||||||
Content,
|
// AudioContent,
|
||||||
ContentType,
|
// Content,
|
||||||
ImageContent,
|
// ContentType,
|
||||||
StickerContent,
|
// ImageContent,
|
||||||
TextContent,
|
// StickerContent,
|
||||||
} from './wire/chat_message'
|
// TextContent,
|
||||||
export { ChatMessage } from './wire/chat_message'
|
// } from './wire/chat_message'
|
||||||
export { getPredefinedBootstrapNodes } from 'js-waku'
|
// export { ChatMessage } from './wire/chat_message'
|
||||||
|
// export { getPredefinedBootstrapNodes } from 'js-waku'
|
||||||
|
|
||||||
|
import { createClient } from './client-v2'
|
||||||
|
|
||||||
|
const COMMUNITY_PUBLIC_KEY =
|
||||||
|
'0x029dd5fecbd689dc11e2a5b399afed92cf1fab65d315b883efca753e8f3882f3bd' // compressed
|
||||||
|
// const COMMUNITY_PUBLIC_KEY =
|
||||||
|
// '0x0403aeff2fdd0044b136e06afa6d69bb563bb7b3fd518bb30c0d5115a2e020840a2247966c2cc9953ed02cc391e8883b3319f63a31e5f5369d0fb72b62b23dfcbd' // compressed
|
||||||
|
|
||||||
|
// import { Community } from '../src/community'
|
||||||
|
// import { Messenger } from '../src/messenger'
|
||||||
|
|
||||||
|
console.log('🚀 > COMMUNITY_PUBLIC_KEY', COMMUNITY_PUBLIC_KEY)
|
||||||
|
;(async () => {
|
||||||
|
const client = await createClient({
|
||||||
|
env: 'test',
|
||||||
|
publicKey: COMMUNITY_PUBLIC_KEY,
|
||||||
|
callback: msgs => {},
|
||||||
|
})
|
||||||
|
|
||||||
|
const communityDescription = await client.getCommunityDescription()
|
||||||
|
|
||||||
|
console.log('meow', communityDescription)
|
||||||
|
|
||||||
|
// console.log(communityDescription)
|
||||||
|
// Retrieve Community's metadata (e.g. description)
|
||||||
|
// const community = await Community.instantiateCommunity(COMMUNITY_PUBLIC_KEY, client)
|
||||||
|
// // Retrieve and subscribe to messages
|
||||||
|
// const messenger = await Messenger.create(, client)
|
||||||
|
// // TODO: Register observers/callbacks
|
||||||
|
// messenger.addObserver(() => {})
|
||||||
|
// await client.stop()
|
||||||
|
})()
|
||||||
|
|
||||||
|
// export {}
|
||||||
|
|
|
@ -39,14 +39,13 @@ export class Messenger {
|
||||||
identity: Identity | undefined,
|
identity: Identity | undefined,
|
||||||
// wakuOptions?: waku.CreateOptions
|
// wakuOptions?: waku.CreateOptions
|
||||||
// TODO: pass waku as client
|
// TODO: pass waku as client
|
||||||
// wakuOptions?: WakuCreateOptions
|
wakuOptions?: waku.CreateOptions
|
||||||
waku: Waku
|
|
||||||
): Promise<Messenger> {
|
): Promise<Messenger> {
|
||||||
// const _wakuOptions = Object.assign(
|
const _wakuOptions = Object.assign(
|
||||||
// { bootstrap: { default: true } },
|
{ bootstrap: { default: true } },
|
||||||
// wakuOptions
|
wakuOptions
|
||||||
// )
|
)
|
||||||
// const waku = await Waku.create(_wakuOptions)
|
const waku = await Waku.create(_wakuOptions)
|
||||||
return new Messenger(identity, waku)
|
return new Messenger(identity, waku)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import { ec } from 'elliptic'
|
||||||
import { idToContentTopic } from './contentTopic'
|
import { idToContentTopic } from './contentTopic'
|
||||||
import { bufToHex, hexToBuf } from './utils'
|
import { bufToHex, hexToBuf } from './utils'
|
||||||
|
|
||||||
import type { Identity } from '.'
|
import type { Identity } from './identity'
|
||||||
|
|
||||||
const EC = new ec('secp256k1')
|
const EC = new ec('secp256k1')
|
||||||
const partitionsNum = new BN(5000)
|
const partitionsNum = new BN(5000)
|
||||||
|
|
20
yarn.lock
20
yarn.lock
|
@ -7597,6 +7597,7 @@ node-addon-api@^4.3.0:
|
||||||
|
|
||||||
"node-fetch@https://registry.npmjs.org/@achingbrain/node-fetch/-/node-fetch-2.6.7.tgz":
|
"node-fetch@https://registry.npmjs.org/@achingbrain/node-fetch/-/node-fetch-2.6.7.tgz":
|
||||||
version "2.6.7"
|
version "2.6.7"
|
||||||
|
uid "1b5d62978f2ed07b99444f64f0df39f960a6d34d"
|
||||||
resolved "https://registry.npmjs.org/@achingbrain/node-fetch/-/node-fetch-2.6.7.tgz#1b5d62978f2ed07b99444f64f0df39f960a6d34d"
|
resolved "https://registry.npmjs.org/@achingbrain/node-fetch/-/node-fetch-2.6.7.tgz#1b5d62978f2ed07b99444f64f0df39f960a6d34d"
|
||||||
|
|
||||||
node-forge@^1.2.1:
|
node-forge@^1.2.1:
|
||||||
|
@ -8437,6 +8438,25 @@ protobufjs@^6.10.2, protobufjs@^6.11.2, protobufjs@^6.8.8:
|
||||||
"@types/node" ">=13.7.0"
|
"@types/node" ">=13.7.0"
|
||||||
long "^4.0.0"
|
long "^4.0.0"
|
||||||
|
|
||||||
|
protobufjs@^6.11.3:
|
||||||
|
version "6.11.3"
|
||||||
|
resolved "https://registry.yarnpkg.com/protobufjs/-/protobufjs-6.11.3.tgz#637a527205a35caa4f3e2a9a4a13ddffe0e7af74"
|
||||||
|
integrity sha512-xL96WDdCZYdU7Slin569tFX712BxsxslWwAfAhCYjQKGTq7dAU91Lomy6nLLhh/dyGhk/YH4TwTSRxTzhuHyZg==
|
||||||
|
dependencies:
|
||||||
|
"@protobufjs/aspromise" "^1.1.2"
|
||||||
|
"@protobufjs/base64" "^1.1.2"
|
||||||
|
"@protobufjs/codegen" "^2.0.4"
|
||||||
|
"@protobufjs/eventemitter" "^1.1.0"
|
||||||
|
"@protobufjs/fetch" "^1.1.0"
|
||||||
|
"@protobufjs/float" "^1.0.2"
|
||||||
|
"@protobufjs/inquire" "^1.1.0"
|
||||||
|
"@protobufjs/path" "^1.1.2"
|
||||||
|
"@protobufjs/pool" "^1.1.0"
|
||||||
|
"@protobufjs/utf8" "^1.1.0"
|
||||||
|
"@types/long" "^4.0.1"
|
||||||
|
"@types/node" ">=13.7.0"
|
||||||
|
long "^4.0.0"
|
||||||
|
|
||||||
protons-runtime@^1.0.4:
|
protons-runtime@^1.0.4:
|
||||||
version "1.0.4"
|
version "1.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/protons-runtime/-/protons-runtime-1.0.4.tgz#85db97f82fb03a1205eafb591904736ba34e2972"
|
resolved "https://registry.yarnpkg.com/protons-runtime/-/protons-runtime-1.0.4.tgz#85db97f82fb03a1205eafb591904736ba34e2972"
|
||||||
|
|
Loading…
Reference in New Issue