@yz-social/civildefense.io 4.4.1 → 4.4.3
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/index.js
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export { P2PWebNetwork } from "./public/javascripts/p2pWebNetwork.js";
|
|
2
2
|
export { agentTopic, alertTopic, canonicalTag } from "./public/javascripts/versions.js";
|
|
3
|
+
export { getContainingCells } from "./public/javascripts/s2.js";
|
|
4
|
+
export { location } from "./server/getLocation.js";
|
package/package.json
CHANGED
|
@@ -136,7 +136,7 @@ export class Agent {
|
|
|
136
136
|
// Our downsampling is such that we do not need to chunkify.
|
|
137
137
|
// if (type === 'avatar') {
|
|
138
138
|
// const blob = await P2PWebNetwork.dataURL2blob(value);
|
|
139
|
-
// payload = await contact.chunkifyBlob({blob, region});
|
|
139
|
+
// payload = (await contact.chunkifyBlob({blob, region})).topic;
|
|
140
140
|
// }
|
|
141
141
|
return contact.publish({eventName, region, owner, payload});
|
|
142
142
|
}
|
|
@@ -486,7 +486,7 @@ export class Marker { // A wrapper around L.marker
|
|
|
486
486
|
inputElement.querySelector('md-filled-icon-button').toggleAttribute('disabled', true);
|
|
487
487
|
const contact = await networkPromise;
|
|
488
488
|
if (files.length) {
|
|
489
|
-
const file = await contact.chunkifyBlob({blob: files[0], region});
|
|
489
|
+
const {topic:file} = await contact.chunkifyBlob({blob: files[0], region});
|
|
490
490
|
payload = {message: payload, file};
|
|
491
491
|
}
|
|
492
492
|
await contact.publish({eventName: subject, region, payload}); // Publish the new reply.
|
|
@@ -38,7 +38,7 @@ export class P2PWebNetwork {
|
|
|
38
38
|
const network = new this();
|
|
39
39
|
Object.assign(network, {infoLogger, debugLogger, identity, transport, node, peer});
|
|
40
40
|
network.resetStatePromises();
|
|
41
|
-
network.info(
|
|
41
|
+
network.info(`Created network node for kernel ${this.kernelVersion} region 0x${this.regionCode(region.lat, region.lng).toString(16)}.`);
|
|
42
42
|
await network.connect({synapseCount, timeoutMs});
|
|
43
43
|
return network;
|
|
44
44
|
}
|
|
@@ -159,9 +159,8 @@ export class P2PWebNetwork {
|
|
|
159
159
|
const topic = {name: uuidv4(), region, owner};
|
|
160
160
|
const buffer = await blob.arrayBuffer();
|
|
161
161
|
const u8 = new Uint8Array(buffer);
|
|
162
|
-
console.log('blob', blob.size, u8.length);
|
|
163
|
-
|
|
164
|
-
return data.topic;
|
|
162
|
+
//console.log('blob', blob.size, u8.length);
|
|
163
|
+
return await publishChunkedBytes(this.peer, u8, {topic, signWith, mime, name, ...rest});
|
|
165
164
|
}
|
|
166
165
|
async assembleChunkedDataURL(topic) { // Promise {bytes, mime, name, dataURL} that was chunkified to topic.
|
|
167
166
|
const data = await receiveChunkedBytes(this.peer, topic, {/*, onProgress: console.log*/});
|
|
@@ -211,6 +210,9 @@ export class P2PWebNetwork {
|
|
|
211
210
|
static regionCode(lat, lng) { // Answer containing region code.
|
|
212
211
|
return geoCellId(lat, lng);
|
|
213
212
|
}
|
|
213
|
+
static regionCenter(regionCode) {
|
|
214
|
+
return geoCellCenter(regionCode);
|
|
215
|
+
}
|
|
214
216
|
static delay(ms, result) { // Promise result after ms milliseconds.
|
|
215
217
|
return new Promise(resolve => setTimeout(resolve, ms, result));
|
|
216
218
|
}
|
|
@@ -224,7 +226,7 @@ export class P2PWebNetwork {
|
|
|
224
226
|
static canonicalizeRegion(lat, lng) {
|
|
225
227
|
// Answer a {lat, lng} that is the center of a top-level Axona region containing the given {lat, lng}.
|
|
226
228
|
// E.g., a precise location gets anonymized to containing top-level cell center.
|
|
227
|
-
return
|
|
229
|
+
return this.regionCenter(this.regionCode(lat, lng));
|
|
228
230
|
}
|
|
229
231
|
get synaptomeSize() { // Safely answer the number of connections.
|
|
230
232
|
return this.node.synaptome?.size ?? 0;
|
package/public/service-worker.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { Request, Response, URL, clients} = self;
|
|
2
2
|
// Little point in trying to automatically pull this through package.json, as we need a byte change in THIS file to trigger a new worker.
|
|
3
|
-
const serviceVersion = '4.4.
|
|
3
|
+
const serviceVersion = '4.4.3';
|
|
4
4
|
|
|
5
5
|
async function cacheFirst({request, event}) {
|
|
6
6
|
// Handle request from any cache, else fetch and store it in serviceCache.
|
package/server/getLocation.js
CHANGED
|
@@ -6,7 +6,8 @@ import fs from 'fs/promises';
|
|
|
6
6
|
import { resolve } from './dirname.js';
|
|
7
7
|
const filename = './location.json';
|
|
8
8
|
export const data = await import(filename, {with: { type: 'json' }})
|
|
9
|
-
.catch(async
|
|
9
|
+
.catch(async error => {
|
|
10
|
+
console.log(error);
|
|
10
11
|
const response = await fetch('https://ipinfo.io/json');
|
|
11
12
|
const string = await response.text();
|
|
12
13
|
console.log('Estimating location as', string);
|
package/server/location.json
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
"org": "AS7018 AT&T Enterprises, LLC",
|
|
9
|
-
"postal": "94061",
|
|
10
|
-
"timezone": "America/Los_Angeles",
|
|
11
|
-
"readme": "https://ipinfo.io/missingauth"
|
|
12
|
-
}
|
|
2
|
+
"uswest/80": "37.4852,-122.2364",
|
|
3
|
+
"useast/89": "40,-75",
|
|
4
|
+
"uscentle/88": "35,-83",
|
|
5
|
+
"easteu/47": "50,17",
|
|
6
|
+
"loc": "37.4852,-122.2364"
|
|
7
|
+
}
|