@celljs/ta-town 4.34.0 → 4.36.0
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/package.json +4 -4
- package/web/index.js +61 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@celljs/ta-town",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.36.0",
|
|
4
4
|
"description": "A pi package for Ta: a pixel town after Stanford's Smallville, where the double, the agents of ta-channels and the tasks live and go about what they are doing",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package"
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"watch": "tsc -b -w --preserveWatchOutput"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@celljs/ta-protocol": "4.
|
|
29
|
-
"@celljs/ta-relay": "4.
|
|
30
|
-
"@celljs/ta-web": "4.
|
|
28
|
+
"@celljs/ta-protocol": "4.36.0",
|
|
29
|
+
"@celljs/ta-relay": "4.36.0",
|
|
30
|
+
"@celljs/ta-web": "4.36.0",
|
|
31
31
|
"@types/react": "^19.3.0",
|
|
32
32
|
"phaser": "^4.2.1"
|
|
33
33
|
},
|
package/web/index.js
CHANGED
|
@@ -1789,8 +1789,9 @@ var TownModel;
|
|
|
1789
1789
|
}
|
|
1790
1790
|
TownModel.benchTasks = benchTasks;
|
|
1791
1791
|
function standing(team) {
|
|
1792
|
-
const
|
|
1793
|
-
|
|
1792
|
+
const inTeams = new Set(team.channels.filter((channel) => channel.by === "ta").flatMap((channel) => channel.members));
|
|
1793
|
+
const inOwn = new Set(team.channels.filter((channel) => channel.by !== "ta").flatMap((channel) => channel.members));
|
|
1794
|
+
return team.agents.filter((agent) => !agent.temporary || !inTeams.has(agent.id) || inOwn.has(agent.id));
|
|
1794
1795
|
}
|
|
1795
1796
|
TownModel.standing = standing;
|
|
1796
1797
|
function of(input) {
|
|
@@ -5037,6 +5038,50 @@ function TalkBar({
|
|
|
5037
5038
|
})));
|
|
5038
5039
|
}
|
|
5039
5040
|
|
|
5041
|
+
// ../ta-relay/esm/common/relay-chat-record.js
|
|
5042
|
+
var RELAY_CHAT_RECORD_LINES = 100;
|
|
5043
|
+
var RELAY_CHAT_RECORD_TEXT = 300;
|
|
5044
|
+
var RELAY_CHAT_RECORD_BYTES = 6 * 1024;
|
|
5045
|
+
var encoder = new TextEncoder;
|
|
5046
|
+
var RelayChatRecordUtil;
|
|
5047
|
+
(function(RelayChatRecordUtil2) {
|
|
5048
|
+
function of(title, lines) {
|
|
5049
|
+
const kept = [];
|
|
5050
|
+
const head = { title: title.slice(0, 80), lines: [] };
|
|
5051
|
+
let bytes = size(head);
|
|
5052
|
+
for (const line of [...lines].reverse()) {
|
|
5053
|
+
if (kept.length >= RELAY_CHAT_RECORD_LINES) {
|
|
5054
|
+
break;
|
|
5055
|
+
}
|
|
5056
|
+
const text = line.text.trim().slice(0, RELAY_CHAT_RECORD_TEXT);
|
|
5057
|
+
if (!text) {
|
|
5058
|
+
continue;
|
|
5059
|
+
}
|
|
5060
|
+
const each = { name: line.name.slice(0, 64), text, at: line.at };
|
|
5061
|
+
const more = size(each) + 1;
|
|
5062
|
+
if (bytes + more > RELAY_CHAT_RECORD_BYTES) {
|
|
5063
|
+
break;
|
|
5064
|
+
}
|
|
5065
|
+
bytes += more;
|
|
5066
|
+
kept.unshift(each);
|
|
5067
|
+
}
|
|
5068
|
+
return kept.length ? { ...head, lines: kept } : undefined;
|
|
5069
|
+
}
|
|
5070
|
+
RelayChatRecordUtil2.of = of;
|
|
5071
|
+
function parse(value) {
|
|
5072
|
+
const record = value;
|
|
5073
|
+
if (!record || typeof record.title !== "string" || !Array.isArray(record.lines)) {
|
|
5074
|
+
return;
|
|
5075
|
+
}
|
|
5076
|
+
const lines = record.lines.filter((line) => line && typeof line.name === "string" && typeof line.text === "string" && Number.isFinite(line.at)).slice(-RELAY_CHAT_RECORD_LINES).map((line) => ({ name: line.name.slice(0, 64), text: line.text.slice(0, RELAY_CHAT_RECORD_TEXT), at: line.at }));
|
|
5077
|
+
return lines.length ? { title: record.title.slice(0, 80), lines } : undefined;
|
|
5078
|
+
}
|
|
5079
|
+
RelayChatRecordUtil2.parse = parse;
|
|
5080
|
+
function size(value) {
|
|
5081
|
+
return encoder.encode(JSON.stringify(value)).length;
|
|
5082
|
+
}
|
|
5083
|
+
})(RelayChatRecordUtil || (RelayChatRecordUtil = {}));
|
|
5084
|
+
|
|
5040
5085
|
// ../ta-relay/esm/common/relay-bytes.js
|
|
5041
5086
|
var RelayBytes;
|
|
5042
5087
|
(function(RelayBytes2) {
|
|
@@ -5109,7 +5154,7 @@ var RELAY_PICTURE_MAX_CHARS = 16 * 1024;
|
|
|
5109
5154
|
var RELAY_HUB_LOG_CHARS = 4 * 1024 * 1024;
|
|
5110
5155
|
|
|
5111
5156
|
// ../ta-relay/esm/common/relay-identity.js
|
|
5112
|
-
var
|
|
5157
|
+
var encoder2 = new TextEncoder;
|
|
5113
5158
|
var decoder = new TextDecoder;
|
|
5114
5159
|
var subtle = () => globalThis.crypto.subtle;
|
|
5115
5160
|
var SIGN = { name: "ECDSA", namedCurve: "P-256" };
|
|
@@ -5119,12 +5164,12 @@ var RelayKeys;
|
|
|
5119
5164
|
(function(RelayKeys2) {
|
|
5120
5165
|
async function hkdf(key, salt, info) {
|
|
5121
5166
|
const secret = await subtle().importKey("raw", key, "HKDF", false, ["deriveBits"]);
|
|
5122
|
-
const bits = await subtle().deriveBits({ name: "HKDF", hash: "SHA-256", salt, info:
|
|
5167
|
+
const bits = await subtle().deriveBits({ name: "HKDF", hash: "SHA-256", salt, info: encoder2.encode(info) }, secret, 256);
|
|
5123
5168
|
return new Uint8Array(bits);
|
|
5124
5169
|
}
|
|
5125
5170
|
RelayKeys2.hkdf = hkdf;
|
|
5126
5171
|
async function sha256(bytes) {
|
|
5127
|
-
const data = typeof bytes === "string" ?
|
|
5172
|
+
const data = typeof bytes === "string" ? encoder2.encode(bytes) : bytes;
|
|
5128
5173
|
return new Uint8Array(await subtle().digest("SHA-256", data));
|
|
5129
5174
|
}
|
|
5130
5175
|
RelayKeys2.sha256 = sha256;
|
|
@@ -5134,7 +5179,7 @@ var RelayKeys;
|
|
|
5134
5179
|
RelayKeys2.hash = hash2;
|
|
5135
5180
|
async function hmac(key, text) {
|
|
5136
5181
|
const imported = await subtle().importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
5137
|
-
return RelayBytes.toBase64(new Uint8Array(await subtle().sign("HMAC", imported,
|
|
5182
|
+
return RelayBytes.toBase64(new Uint8Array(await subtle().sign("HMAC", imported, encoder2.encode(text))));
|
|
5138
5183
|
}
|
|
5139
5184
|
RelayKeys2.hmac = hmac;
|
|
5140
5185
|
function aesKey(key) {
|
|
@@ -5143,7 +5188,7 @@ var RelayKeys;
|
|
|
5143
5188
|
RelayKeys2.aesKey = aesKey;
|
|
5144
5189
|
async function seal(key, text) {
|
|
5145
5190
|
const iv = RelayBytes.random(12);
|
|
5146
|
-
const sealed = await subtle().encrypt({ name: "AES-GCM", iv }, key,
|
|
5191
|
+
const sealed = await subtle().encrypt({ name: "AES-GCM", iv }, key, encoder2.encode(text));
|
|
5147
5192
|
return RelayBytes.toBase64(RelayBytes.concat(iv, new Uint8Array(sealed)));
|
|
5148
5193
|
}
|
|
5149
5194
|
RelayKeys2.seal = seal;
|
|
@@ -5208,12 +5253,12 @@ var RelayIdentityUtil;
|
|
|
5208
5253
|
RelayIdentityUtil2.withLook = withLook;
|
|
5209
5254
|
async function sign(identity, text) {
|
|
5210
5255
|
const key = await subtle().importKey("jwk", identity.signKey, SIGN, false, ["sign"]);
|
|
5211
|
-
return RelayBytes.toBase64(new Uint8Array(await subtle().sign(SIGNATURE, key,
|
|
5256
|
+
return RelayBytes.toBase64(new Uint8Array(await subtle().sign(SIGNATURE, key, encoder2.encode(text))));
|
|
5212
5257
|
}
|
|
5213
5258
|
RelayIdentityUtil2.sign = sign;
|
|
5214
5259
|
async function verify(signPublic, text, signature) {
|
|
5215
5260
|
try {
|
|
5216
|
-
return await subtle().verify(SIGNATURE, await importSign(signPublic), RelayBytes.fromBase64(signature),
|
|
5261
|
+
return await subtle().verify(SIGNATURE, await importSign(signPublic), RelayBytes.fromBase64(signature), encoder2.encode(text));
|
|
5217
5262
|
} catch (_a) {
|
|
5218
5263
|
return false;
|
|
5219
5264
|
}
|
|
@@ -5222,7 +5267,7 @@ var RelayIdentityUtil;
|
|
|
5222
5267
|
async function agree(identity, otherBox, salt, info) {
|
|
5223
5268
|
const own = await subtle().importKey("jwk", identity.boxKey, BOX, false, ["deriveBits"]);
|
|
5224
5269
|
const shared = await subtle().deriveBits({ name: "ECDH", public: await importBox(otherBox) }, own, 256);
|
|
5225
|
-
return RelayKeys.hkdf(new Uint8Array(shared),
|
|
5270
|
+
return RelayKeys.hkdf(new Uint8Array(shared), encoder2.encode(salt), info);
|
|
5226
5271
|
}
|
|
5227
5272
|
RelayIdentityUtil2.agree = agree;
|
|
5228
5273
|
function importSign(raw) {
|
|
@@ -5331,7 +5376,8 @@ var RelayRoomChatUtil;
|
|
|
5331
5376
|
...line.task === true && to.length ? { task: true } : {},
|
|
5332
5377
|
...images(line.images),
|
|
5333
5378
|
...files(line.files),
|
|
5334
|
-
...deal(line.deal)
|
|
5379
|
+
...deal(line.deal),
|
|
5380
|
+
...record(line.record)
|
|
5335
5381
|
};
|
|
5336
5382
|
}
|
|
5337
5383
|
RelayRoomChatUtil2.extra = extra;
|
|
@@ -5366,6 +5412,10 @@ var RelayRoomChatUtil;
|
|
|
5366
5412
|
return files2.length ? { files: files2 } : {};
|
|
5367
5413
|
}
|
|
5368
5414
|
RelayRoomChatUtil2.files = files;
|
|
5415
|
+
function record(value) {
|
|
5416
|
+
const parsed = RelayChatRecordUtil.parse(value);
|
|
5417
|
+
return parsed ? { record: parsed } : {};
|
|
5418
|
+
}
|
|
5369
5419
|
function deal(value) {
|
|
5370
5420
|
const parsed = RelayDealUtil.parse(value);
|
|
5371
5421
|
return parsed ? { deal: parsed } : {};
|