@peerbit/server 1.0.15 → 1.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/ui/index.html CHANGED
@@ -23,7 +23,7 @@
23
23
  Learn how to configure a non-root public URL by running `npm run build`.
24
24
  -->
25
25
  <title>Peerbit</title>
26
- <script type="module" crossorigin src="/assets/index-a842ec7a.js"></script>
26
+ <script type="module" crossorigin src="/assets/index-40169014.js"></script>
27
27
  <link rel="stylesheet" href="/assets/index-5265c558.css">
28
28
  </head>
29
29
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peerbit/server",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "author": "dao.xyz",
5
5
  "repository": {
6
6
  "type": "git",
@@ -43,9 +43,9 @@
43
43
  "test:integration": "node ../node_modules/.bin/jest test -c ../../../jest.config.integration.ts --runInBand --forceExit"
44
44
  },
45
45
  "devDependencies": {
46
- "@peerbit/string": "1.0.14",
46
+ "@peerbit/string": "2.0.0",
47
47
  "@peerbit/test-lib": "^0.0.1",
48
- "@peerbit/test-utils": "1.0.12",
48
+ "@peerbit/test-utils": "1.0.14",
49
49
  "@types/yargs": "^17.0.24",
50
50
  "aws-sdk": "^2.1259.0",
51
51
  "dotenv": "^16.1.4"
@@ -54,8 +54,8 @@
54
54
  "@aws-sdk/client-route-53": "^3.345.0",
55
55
  "@dao-xyz/libp2p-noise": "^12.0.1",
56
56
  "axios": "^1.4.0",
57
- "peerbit": "1.1.5",
57
+ "peerbit": "1.1.7",
58
58
  "yargs": "^17.7.2"
59
59
  },
60
- "gitHead": "7014094c3d867ca007862f5b04753baa729de009"
60
+ "gitHead": "32f61ad9f3d5906e13d46f2a80f61c1826a3e817"
61
61
  }
package/src/api.ts CHANGED
@@ -9,6 +9,7 @@ import { Libp2p } from "libp2p";
9
9
  import { getConfigDir, getCredentialsPath, NotFoundError } from "./config.js";
10
10
  import { setMaxListeners } from "events";
11
11
  import { create } from "./client.js";
12
+ import { createTestDomain } from "./domain.js";
12
13
 
13
14
  export const SSL_PORT = 9002;
14
15
  export const LOCAL_PORT = 8082;
@@ -97,8 +98,11 @@ export const loadOrCreatePassword = async (): Promise<string> => {
97
98
  throw error;
98
99
  }
99
100
  };
100
- export const startServerWithNode = async (directory: string) => {
101
- const peer = await create(directory);
101
+ export const startServerWithNode = async (
102
+ directory: string,
103
+ domain?: string
104
+ ) => {
105
+ const peer = await create(directory, domain);
102
106
  const server = await startServer(peer);
103
107
  const printNodeInfo = async () => {
104
108
  console.log("Starting node with address(es): ");
package/src/cli.ts CHANGED
@@ -25,9 +25,18 @@ export const cli = async (args?: string[]) => {
25
25
  type: "string",
26
26
  default: await getConfigDir(),
27
27
  },
28
+ domain: {
29
+ describe: "Domain to use when announcing Libp2p multiaddress",
30
+ defaultDescription: "Test domain from public IP",
31
+ type: "string",
32
+ default: undefined,
33
+ },
28
34
  },
29
35
  handler: async (args) => {
30
- await startServerWithNode(args.directory);
36
+ await startServerWithNode(
37
+ args.directory,
38
+ args.domain ? args.domain : await createTestDomain()
39
+ );
31
40
  },
32
41
  })
33
42
  .command("domain", "Setup a domain and certificate", (yargs) => {
package/src/client.ts CHANGED
@@ -1,10 +1,13 @@
1
1
  import { DirectSub } from "@peerbit/pubsub";
2
2
  import { Peerbit } from "peerbit";
3
3
 
4
- export const create = (directory: string) => {
4
+ export const create = (directory: string, domain?: string) => {
5
5
  return Peerbit.create({
6
6
  libp2p: {
7
7
  addresses: {
8
+ announce: domain
9
+ ? [`/dns4/${domain}/tcp/8001`, `/dns4/${domain}/tcp/8002/ws`]
10
+ : undefined,
8
11
  listen: ["/ip4/127.0.0.1/tcp/8001", "/ip4/127.0.0.1/tcp/8002/ws"],
9
12
  },
10
13
  connectionManager: {