alice-and-bot 1.0.78 → 1.0.79
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/README.md +32 -2
- package/_dist/lit/core/subscriptions.d.ts.map +1 -1
- package/_dist/mod.d.ts +1 -0
- package/_dist/mod.d.ts.map +1 -1
- package/_dist/protocol/src/clientApi.d.ts.map +1 -1
- package/_dist/protocol/src/retention.d.ts +4 -0
- package/_dist/protocol/src/retention.d.ts.map +1 -0
- package/{chunk-GTVFIQQN.js → chunk-45LBWUH3.js} +44 -13
- package/components.js +71 -12
- package/mod.js +7 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,6 +7,7 @@ that: free keypair identities, desktop + mobile app for humans, ChatGPT-style or
|
|
|
7
7
|
side widgets for websites, signed webhooks, and an MCP server.
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/alice-and-bot)
|
|
10
|
+
[](https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.uriva/alice-and-bot)
|
|
10
11
|
[](https://jsr.io/@alice-and-bot/core)
|
|
11
12
|
[](LICENSE)
|
|
12
13
|
[](https://aliceandbot.com)
|
|
@@ -57,7 +58,17 @@ import { createIdentity, sendMessage } from "@alice-and-bot/core";
|
|
|
57
58
|
|
|
58
59
|
### Quick start (30 seconds)
|
|
59
60
|
|
|
60
|
-
Run
|
|
61
|
+
Run a standalone multi-agent E2E encrypted group chat in **Node.js**
|
|
62
|
+
([`example/node-quickstart.mjs`](example/node-quickstart.mjs)) or start an
|
|
63
|
+
Ed25519-verified webhook bot
|
|
64
|
+
([`example/webhook-bot.mjs`](example/webhook-bot.mjs)):
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
npm install alice-and-bot
|
|
68
|
+
node example/node-quickstart.mjs
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Or run the standalone **Deno** example directly without cloning:
|
|
61
72
|
|
|
62
73
|
```sh
|
|
63
74
|
deno run -A https://raw.githubusercontent.com/uriva/alice-and-bot/main/example/cross-harness-group-chat.ts
|
|
@@ -71,7 +82,7 @@ import {
|
|
|
71
82
|
createIdentity,
|
|
72
83
|
sendMessage,
|
|
73
84
|
setWebhook,
|
|
74
|
-
} from "
|
|
85
|
+
} from "alice-and-bot";
|
|
75
86
|
|
|
76
87
|
const alice = await createIdentity("Alice", "alice");
|
|
77
88
|
const coder = await createIdentity("Coder Agent", "coder_bot");
|
|
@@ -778,6 +789,21 @@ To run your own alice-and-bot server:
|
|
|
778
789
|
EOF
|
|
779
790
|
gsutil cors set cors.json gs://your-bucket-name
|
|
780
791
|
```
|
|
792
|
+
7. (Optional) Configure a 30-day lifecycle rule to auto-delete expired
|
|
793
|
+
attachments (matching the hosted service's 30-day rolling retention):
|
|
794
|
+
```sh
|
|
795
|
+
cat > lifecycle.json << 'EOF'
|
|
796
|
+
{
|
|
797
|
+
"rule": [
|
|
798
|
+
{
|
|
799
|
+
"action": { "type": "Delete" },
|
|
800
|
+
"condition": { "age": 30, "matchesPrefix": ["attachments/"] }
|
|
801
|
+
}
|
|
802
|
+
]
|
|
803
|
+
}
|
|
804
|
+
EOF
|
|
805
|
+
gcloud storage buckets update gs://your-bucket-name --lifecycle-file=lifecycle.json
|
|
806
|
+
```
|
|
781
807
|
|
|
782
808
|
### 3. Backend Deployment (Cloudflare Workers)
|
|
783
809
|
|
|
@@ -837,3 +863,7 @@ To host your own widget:
|
|
|
837
863
|
signed by the notification server with Ed25519 (`X-Alice-Signature` /
|
|
838
864
|
`serverSignature`), verified with timestamp freshness and per-message replay
|
|
839
865
|
deduplication in `handleWebhookUpdate` / `verifyWebhookOrigin`.
|
|
866
|
+
- **30-day rolling retention:** On the hosted service, encrypted messages and
|
|
867
|
+
encrypted file attachments are automatically deleted after 30 days.
|
|
868
|
+
Conversation shells (metadata and wrapped keys), canvases, profiles, and Paid
|
|
869
|
+
Inbox records are kept so ongoing chats and bot integrations continue working.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscriptions.d.ts","sources":["../../../lit/core/subscriptions.ts"],"names":[],"mappings":"AAGA,SAEE,KAAK,WAAW,EAChB,KAAK,iBAAiB,0CAMiB;AA6BzC,OAAO,cAAM,mBAAoB,GAAG,MAAM,KAAG,MAAM,CACM;AAEzD,YAAY;EACV,IAAI,MAAM;EACV,OAAO,MAAM;EACb;IAAgB,eAAe,MAAM;IAAE,OAAO,MAAM;IAAE,SAAS,MAAM;;EACrE,YAAY,MAAM;EAClB;IAAe,eAAe,MAAM;;;AA4BtC,OAAO,cAAM,yBACX,kBAAkB,cAAc,MAAM,EACtC,WAAW,eAAe,iBAAiB,IAAI,KAAK,IAAI,WACjD,IAAI,CA2BX;AAmSF,YAAY;EACV,UAAU,sBAAsB,IAAI;EACpC,aAAa,OAAO;EACpB,gBAAgB,IAAI;;
|
|
1
|
+
{"version":3,"file":"subscriptions.d.ts","sources":["../../../lit/core/subscriptions.ts"],"names":[],"mappings":"AAGA,SAEE,KAAK,WAAW,EAChB,KAAK,iBAAiB,0CAMiB;AA6BzC,OAAO,cAAM,mBAAoB,GAAG,MAAM,KAAG,MAAM,CACM;AAEzD,YAAY;EACV,IAAI,MAAM;EACV,OAAO,MAAM;EACb;IAAgB,eAAe,MAAM;IAAE,OAAO,MAAM;IAAE,SAAS,MAAM;;EACrE,YAAY,MAAM;EAClB;IAAe,eAAe,MAAM;;;AA4BtC,OAAO,cAAM,yBACX,kBAAkB,cAAc,MAAM,EACtC,WAAW,eAAe,iBAAiB,IAAI,KAAK,IAAI,WACjD,IAAI,CA2BX;AAmSF,YAAY;EACV,UAAU,sBAAsB,IAAI;EACpC,aAAa,OAAO;EACpB,gBAAgB,IAAI;;AAwhBtB,OAAO,cAAM,2BACX,eAAe,MAAM,EACrB,WACE;EACE,IAAI,MAAM;EACV,OAAO,MAAM;EACb,SAAS,MAAM;EACf,QAAQ,MAAM;EACd,WAAW,MAAM;IACf,IAAI,KACL,IAAI,WACF,IAAI,CAUT;AAiRJ,OAAO,cAAM,0BACX,aAAa,aACb,cAAc,MAAM,IACpB,iBAAiB,IAAI,MAAM,KAAK,IAAI,EACpC,yBACO,IAAI,CAmEX"}
|
package/_dist/mod.d.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { buildSignedRequest, type SignedRequest } from "./protocol/src/authClien
|
|
|
6
6
|
export type { GetMessagesResult } from "./backend/src/api.js";
|
|
7
7
|
export { type Attachment, type AudioAttachment, buildUiUpdateUrl, chatWithMeLink, createIdentity, type Credentials, type DecipheredMessage, downloadAttachment, type FileAttachment, fileSizeLimits, generateTransferUrl, getConversationKey, handleWebhookUpdate, type ImageAttachment, type LocationAttachment, parseChatWithUrl, renameConversation, resolveHandle, sendMessage, sendMessageWithKey, setAlias, setAvatar, setName, uiUpdateUrl, uploadAttachment, type VideoAttachment, type WebhookUpdate } from "./protocol/src/clientApi.js";
|
|
8
8
|
export { maxEncryptedMessageLength, maxTextLength } from "./protocol/src/attachmentLimits.js";
|
|
9
|
+
export { isAttachmentExpiredError, retentionDays, retentionMs } from "./protocol/src/retention.js";
|
|
9
10
|
export { shortIdFromPublicSignKey, shortIdLength } from "./protocol/src/shortId.js";
|
|
10
11
|
export { defaultWebhookServerPublicKey, resetSeenWebhookMessages, signWebhookOrigin, verifyWebhookOrigin } from "./protocol/src/webhookAuth.js";
|
|
11
12
|
export { setDarkModeOverride } from "./lit/core/dark-mode.js";
|
package/_dist/mod.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAYA,cAAc,iBAAiB,+BAA+B;AAC9D,SAEE,KAAK,WAAW,EAChB,KAAK,iBAAiB,sCAKa;AAErC,cAAc,YAAY,iCAAiC;AAC3D,SACE,oBAAoB,EACpB,wBAAwB,EACxB,YAAY,EACZ,UAAU,EACV,UAAU,+BACkB;AAC9B,SACE,kBAAkB,EAClB,KAAK,aAAa,uCACkB;AACtC,cAAc,iBAAiB,+BAA+B;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
|
seenWebhookMessages.clear();
|
|
95
95
|
};
|
|
96
96
|
|
|
97
|
+
// protocol/src/retention.ts
|
|
98
|
+
var retentionDays = 30;
|
|
99
|
+
var retentionMs = retentionDays * 24 * 60 * 60 * 1e3;
|
|
100
|
+
var attachmentExpiredErrorPrefix = "Attachment expired";
|
|
101
|
+
var createAttachmentExpiredError = (status) => new Error(`${attachmentExpiredErrorPrefix} (${status})`);
|
|
102
|
+
var isAttachmentExpiredError = (error) => error instanceof Error && error.message.startsWith(attachmentExpiredErrorPrefix);
|
|
103
|
+
var isTimestampExpired = (timestamp, nowMs = Date.now()) => timestamp > 0 && nowMs - timestamp >= retentionMs;
|
|
104
|
+
|
|
97
105
|
// protocol/src/clientApi.ts
|
|
98
106
|
import stringify2 from "safe-stable-stringify";
|
|
99
107
|
|
|
@@ -579,6 +587,9 @@ var downloadAttachment = async ({ url, conversationKey }) => {
|
|
|
579
587
|
throw new Error("Untrusted attachment URL");
|
|
580
588
|
}
|
|
581
589
|
const response = await fetch(url);
|
|
590
|
+
if (response.status === 404 || response.status === 410) {
|
|
591
|
+
throw createAttachmentExpiredError(response.status);
|
|
592
|
+
}
|
|
582
593
|
if (!response.ok) {
|
|
583
594
|
throw new Error(`Download failed: ${response.status} ${await response.text()}`);
|
|
584
595
|
}
|
|
@@ -957,12 +968,12 @@ var subscribeColdBootstrap = (publicSignKey, listener) => {
|
|
|
957
968
|
};
|
|
958
969
|
var authenticateIdentity = async (credentials) => {
|
|
959
970
|
await Promise.resolve();
|
|
960
|
-
if (!await canSignWithPrivateKey(credentials.privateSignKey)) return
|
|
971
|
+
if (!await canSignWithPrivateKey(credentials.privateSignKey)) return "ok";
|
|
961
972
|
const expectedEmail = await instantEmailFromPublicSignKey(credentials.publicSignKey);
|
|
962
973
|
const current = await accessDb().getAuth().catch(() => null);
|
|
963
974
|
if (current?.email === expectedEmail) {
|
|
964
975
|
coldBootstrapHints.delete(credentials.publicSignKey);
|
|
965
|
-
return
|
|
976
|
+
return "ok";
|
|
966
977
|
}
|
|
967
978
|
const hints = coldBootstrapHints.get(credentials.publicSignKey);
|
|
968
979
|
coldBootstrapHints.delete(credentials.publicSignKey);
|
|
@@ -984,19 +995,22 @@ var authenticateIdentity = async (credentials) => {
|
|
|
984
995
|
coldBootstrapListeners.get(credentials.publicSignKey)?.forEach((fn) => fn(bootstrap));
|
|
985
996
|
}
|
|
986
997
|
await accessDb().auth.signInWithToken(res.token);
|
|
987
|
-
return
|
|
998
|
+
return "ok";
|
|
988
999
|
}
|
|
989
|
-
|
|
1000
|
+
if ("error" in res && res.error === "not-found") {
|
|
1001
|
+
return "permanent-failure";
|
|
1002
|
+
}
|
|
1003
|
+
return "retry";
|
|
990
1004
|
};
|
|
991
1005
|
var ensureInstantAuthOutcome = (credentials) => {
|
|
992
|
-
if (!credentials) return Promise.resolve(
|
|
1006
|
+
if (!credentials) return Promise.resolve("ok");
|
|
993
1007
|
registerCredentials(credentials);
|
|
994
|
-
if (!isBrowserAuthCapable()) return Promise.resolve(
|
|
1008
|
+
if (!isBrowserAuthCapable()) return Promise.resolve("ok");
|
|
995
1009
|
const existing = inFlightAuth.get(credentials.publicSignKey);
|
|
996
1010
|
if (existing) return existing;
|
|
997
1011
|
const promise = authenticateIdentity(credentials).catch((err) => {
|
|
998
1012
|
console.warn("Failed to sign in to InstantDB", err);
|
|
999
|
-
return
|
|
1013
|
+
return "retry";
|
|
1000
1014
|
}).finally(() => {
|
|
1001
1015
|
inFlightAuth.delete(credentials.publicSignKey);
|
|
1002
1016
|
inFlightBootstrapConv.delete(credentials.publicSignKey);
|
|
@@ -1008,19 +1022,23 @@ var ensureInstantAuthOutcome = (credentials) => {
|
|
|
1008
1022
|
var ensureInstantAuth = (credentials) => ensureInstantAuthOutcome(credentials).then(() => {
|
|
1009
1023
|
});
|
|
1010
1024
|
var resolveCredentials = (credentialsOrKey) => typeof credentialsOrKey === "string" ? lookupRegisteredCredentials(credentialsOrKey) : credentialsOrKey;
|
|
1025
|
+
var defaultMaxAuthRetries = 5;
|
|
1011
1026
|
var defaultAuthRetryDelayMs = (attempt) => Math.min(15e3, 500 * 2 ** Math.max(0, attempt - 1));
|
|
1027
|
+
var normalizeAuthOutcome = (outcome) => outcome === true ? "ok" : outcome === false ? "retry" : outcome;
|
|
1012
1028
|
var makeSubscribeAuthedQuery = (deps) => (credentialsOrKey, query, cb) => {
|
|
1013
1029
|
const creds = resolveCredentials(credentialsOrKey);
|
|
1014
1030
|
if (!creds || !deps.isBrowserAuthCapable()) {
|
|
1015
1031
|
return deps.subscribeQuery(query, cb);
|
|
1016
1032
|
}
|
|
1017
1033
|
const delayFor = deps.retryDelayMs ?? defaultAuthRetryDelayMs;
|
|
1034
|
+
const maxRetries = deps.maxAuthRetries ?? defaultMaxAuthRetries;
|
|
1018
1035
|
const state2 = {
|
|
1019
1036
|
cancelled: false,
|
|
1020
1037
|
expectedEmail: null,
|
|
1021
1038
|
currentEmail: null,
|
|
1022
1039
|
authKnown: false,
|
|
1023
1040
|
authInFlight: false,
|
|
1041
|
+
permanentFailure: false,
|
|
1024
1042
|
retryAttempt: 0,
|
|
1025
1043
|
innerUnsub: void 0,
|
|
1026
1044
|
authUnsub: void 0,
|
|
@@ -1044,19 +1062,27 @@ var makeSubscribeAuthedQuery = (deps) => (credentialsOrKey, query, cb) => {
|
|
|
1044
1062
|
});
|
|
1045
1063
|
};
|
|
1046
1064
|
const triggerAuth = () => {
|
|
1047
|
-
if (state2.cancelled || state2.authInFlight || isAuthedForExpected())
|
|
1065
|
+
if (state2.cancelled || state2.authInFlight || state2.permanentFailure || isAuthedForExpected()) {
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1048
1068
|
clearRetry();
|
|
1049
1069
|
state2.authInFlight = true;
|
|
1050
|
-
deps.ensureAuth(creds).then((
|
|
1070
|
+
deps.ensureAuth(creds).then((rawOutcome) => {
|
|
1051
1071
|
state2.authInFlight = false;
|
|
1052
1072
|
if (state2.cancelled) return;
|
|
1053
|
-
|
|
1073
|
+
const outcome = normalizeAuthOutcome(rawOutcome);
|
|
1074
|
+
if (outcome === "permanent-failure") {
|
|
1075
|
+
state2.permanentFailure = true;
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
if (outcome === "ok" && isAuthedForExpected()) {
|
|
1054
1079
|
state2.retryAttempt = 0;
|
|
1055
1080
|
attachQueryIfReady();
|
|
1056
1081
|
return;
|
|
1057
1082
|
}
|
|
1058
|
-
if (ok && !state2.authKnown) return;
|
|
1083
|
+
if (outcome === "ok" && !state2.authKnown) return;
|
|
1059
1084
|
state2.retryAttempt += 1;
|
|
1085
|
+
if (state2.retryAttempt >= maxRetries) return;
|
|
1060
1086
|
state2.retryTimer = setTimeout(() => {
|
|
1061
1087
|
state2.retryTimer = void 0;
|
|
1062
1088
|
triggerAuth();
|
|
@@ -1069,6 +1095,7 @@ var makeSubscribeAuthedQuery = (deps) => (credentialsOrKey, query, cb) => {
|
|
|
1069
1095
|
state2.currentEmail = auth.user?.email ?? null;
|
|
1070
1096
|
if (isAuthedForExpected()) {
|
|
1071
1097
|
state2.retryAttempt = 0;
|
|
1098
|
+
state2.permanentFailure = false;
|
|
1072
1099
|
clearRetry();
|
|
1073
1100
|
attachQueryIfReady();
|
|
1074
1101
|
return;
|
|
@@ -1634,7 +1661,7 @@ var subscribeConversationKey = makeSubscribeConversationKey({
|
|
|
1634
1661
|
subscribeQuery: (credentials, query, cb) => subscribeAuthedQuery(credentials, query, cb)
|
|
1635
1662
|
});
|
|
1636
1663
|
var initialDecryptBatch = 20;
|
|
1637
|
-
var wakeupCatchUpCooldownMs =
|
|
1664
|
+
var wakeupCatchUpCooldownMs = 3e4;
|
|
1638
1665
|
var postSendReconcileDelaysMs = [
|
|
1639
1666
|
1500,
|
|
1640
1667
|
5e3,
|
|
@@ -1924,7 +1951,7 @@ var makeSubscribeConversationMessagesStream = ({ subscribeInfiniteQuery, keyStor
|
|
|
1924
1951
|
const reconcileAfterSend = () => {
|
|
1925
1952
|
if (syncState.cancelled || !credentials || !conversationId) return;
|
|
1926
1953
|
clearPostSendTimers();
|
|
1927
|
-
syncState.awaitingPostSendLiveCount =
|
|
1954
|
+
syncState.awaitingPostSendLiveCount = 1;
|
|
1928
1955
|
reconcileDelaysMs.forEach((delayMs) => {
|
|
1929
1956
|
const timer = setTimeout(() => {
|
|
1930
1957
|
postSendTimers.delete(timer);
|
|
@@ -2359,6 +2386,10 @@ export {
|
|
|
2359
2386
|
signWebhookOrigin,
|
|
2360
2387
|
verifyWebhookOrigin,
|
|
2361
2388
|
resetSeenWebhookMessages,
|
|
2389
|
+
retentionDays,
|
|
2390
|
+
retentionMs,
|
|
2391
|
+
isAttachmentExpiredError,
|
|
2392
|
+
isTimestampExpired,
|
|
2362
2393
|
sendMessage,
|
|
2363
2394
|
isSilentMessage,
|
|
2364
2395
|
sendMessageWithKey,
|
package/components.js
CHANGED
|
@@ -11,8 +11,10 @@ import {
|
|
|
11
11
|
getCachedConversationKey,
|
|
12
12
|
getOrCreateConversation,
|
|
13
13
|
importIdentity,
|
|
14
|
+
isAttachmentExpiredError,
|
|
14
15
|
isSilentMessage,
|
|
15
16
|
isStoredPushMessage,
|
|
17
|
+
isTimestampExpired,
|
|
16
18
|
isTouchOnlyDevice,
|
|
17
19
|
loadCredentials,
|
|
18
20
|
loadOrCreateCredentials,
|
|
@@ -21,6 +23,7 @@ import {
|
|
|
21
23
|
renameConversation,
|
|
22
24
|
reportError,
|
|
23
25
|
resolveHandle,
|
|
26
|
+
retentionDays,
|
|
24
27
|
saveCredentials,
|
|
25
28
|
sendCanvasEvent,
|
|
26
29
|
sendMessage,
|
|
@@ -41,7 +44,7 @@ import {
|
|
|
41
44
|
subscribeUserName,
|
|
42
45
|
typingTtl,
|
|
43
46
|
uploadAttachment
|
|
44
|
-
} from "./chunk-
|
|
47
|
+
} from "./chunk-45LBWUH3.js";
|
|
45
48
|
import {
|
|
46
49
|
actOnCanvas,
|
|
47
50
|
canvasFromRow,
|
|
@@ -665,7 +668,7 @@ var notifyConversationMessages = (conversationId, messages, updatedAt) => {
|
|
|
665
668
|
if (!conversationId) return;
|
|
666
669
|
liveMessagesListeners.forEach((listener) => listener(conversationId, messages, updatedAt));
|
|
667
670
|
};
|
|
668
|
-
var readCachedConversationPreviews = (publicSignKey) => {
|
|
671
|
+
var readCachedConversationPreviews = (publicSignKey, nowMs = Date.now()) => {
|
|
669
672
|
try {
|
|
670
673
|
const raw = globalThis.localStorage?.getItem(conversationPreviewsCacheKey);
|
|
671
674
|
if (!raw) return {};
|
|
@@ -673,7 +676,7 @@ var readCachedConversationPreviews = (publicSignKey) => {
|
|
|
673
676
|
if (!isRecord(parsed) || parsed.publicSignKey !== publicSignKey || !isRecord(parsed.previews)) {
|
|
674
677
|
return {};
|
|
675
678
|
}
|
|
676
|
-
return Object.fromEntries(Object.entries(parsed.previews).filter((entry) => isValidPreview(entry[1])));
|
|
679
|
+
return Object.fromEntries(Object.entries(parsed.previews).filter((entry) => isValidPreview(entry[1]) && (entry[1].empty === true || !isTimestampExpired(entry[1].timestamp, nowMs))));
|
|
677
680
|
} catch {
|
|
678
681
|
return {};
|
|
679
682
|
}
|
|
@@ -2417,6 +2420,31 @@ var audioBars = Array.from({
|
|
|
2417
2420
|
var fileStyle = (isDark) => `display:flex;align-items:center;gap:8px;padding:8px 12px;border-radius:8px;background:${isDark ? "#ffffff15" : "#00000010"};text-decoration:none;color:inherit`;
|
|
2418
2421
|
var imagePlaceholderStyle = (isDark) => `width:200px;height:150px;border-radius:8px;background:${isDark ? "#ffffff10" : "#00000008"};display:flex;align-items:center;justify-content:center`;
|
|
2419
2422
|
var videoPlaceholderStyle = (isDark) => `display:flex;align-items:center;justify-content:center;max-width:100%;width:480px;aspect-ratio:16/9;border-radius:8px;margin-top:6px;background:${isDark ? "#1a1a1a" : "#e5e7eb"}`;
|
|
2423
|
+
var expiredAttachmentStyle = (isDark) => `display:flex;align-items:center;gap:8px;padding:10px 12px;border-radius:10px;border:1px dashed ${isDark ? "rgba(255,255,255,0.2)" : "rgba(0,0,0,0.18)"};background:${isDark ? "rgba(255,255,255,0.06)" : "rgba(0,0,0,0.04)"};color:${isDark ? "#d1d5db" : "#4b5563"};font-size:13px;max-width:280px`;
|
|
2424
|
+
var expiredSubtitleStyle = (isDark) => `font-size:11px;color:${isDark ? "#9ca3af" : "#6b7280"};margin-top:2px`;
|
|
2425
|
+
var expiredAttachmentLabel = (type) => type === "image" ? "Image expired" : type === "video" ? "Video expired" : type === "audio" ? "Voice note expired" : "File expired";
|
|
2426
|
+
var expiredAttachmentHtml = (attachment, isDark) => html5`
|
|
2427
|
+
<div
|
|
2428
|
+
data-testid="expired-attachment"
|
|
2429
|
+
style="${expiredAttachmentStyle(isDark)}"
|
|
2430
|
+
>
|
|
2431
|
+
<span style="opacity:0.75">${faPaperclip}</span>
|
|
2432
|
+
<div style="min-width:0;flex:1">
|
|
2433
|
+
<div style="font-weight:500">${expiredAttachmentLabel(attachment.type)}</div>
|
|
2434
|
+
<div style="${expiredSubtitleStyle(isDark)}">
|
|
2435
|
+
${attachment.type === "file" ? `${attachment.name} \xB7 ` : ""}Files auto-delete after ${retentionDays} days
|
|
2436
|
+
</div>
|
|
2437
|
+
</div>
|
|
2438
|
+
</div>
|
|
2439
|
+
`;
|
|
2440
|
+
var unavailableAttachmentHtml = (isDark) => html5`
|
|
2441
|
+
<div
|
|
2442
|
+
data-testid="unavailable-attachment"
|
|
2443
|
+
style="${expiredAttachmentStyle(isDark)}"
|
|
2444
|
+
>
|
|
2445
|
+
Unable to load media
|
|
2446
|
+
</div>
|
|
2447
|
+
`;
|
|
2420
2448
|
var isSafeAttachmentSourceUrl = (rawUrl) => {
|
|
2421
2449
|
if (!rawUrl || /[\p{Cc}\\]/u.test(rawUrl)) return false;
|
|
2422
2450
|
try {
|
|
@@ -2440,10 +2468,22 @@ var sanitizeDownloadFilename = (name) => {
|
|
|
2440
2468
|
const nonEmpty = base || "attachment";
|
|
2441
2469
|
return /\.(?:html?|xhtml|svg|js|mjs|xml)$/i.test(nonEmpty) ? `${nonEmpty}.bin` : nonEmpty;
|
|
2442
2470
|
};
|
|
2443
|
-
var
|
|
2471
|
+
var decryptAttachmentOutcome = (decrypt, report) => decrypt().then((url) => isSafeDecryptedMediaUrl(url) ? {
|
|
2472
|
+
status: "ok",
|
|
2473
|
+
url
|
|
2474
|
+
} : {
|
|
2475
|
+
status: "failed"
|
|
2476
|
+
}).catch((error) => {
|
|
2477
|
+
if (isAttachmentExpiredError(error)) {
|
|
2478
|
+
return {
|
|
2479
|
+
status: "expired"
|
|
2480
|
+
};
|
|
2481
|
+
}
|
|
2444
2482
|
console.error("Failed to decrypt attachment:", error);
|
|
2445
2483
|
report("attachment_decrypt_failed");
|
|
2446
|
-
return
|
|
2484
|
+
return {
|
|
2485
|
+
status: "failed"
|
|
2486
|
+
};
|
|
2447
2487
|
});
|
|
2448
2488
|
var ChatAttachment = class extends LitElement4 {
|
|
2449
2489
|
static properties = {
|
|
@@ -2476,6 +2516,12 @@ var ChatAttachment = class extends LitElement4 {
|
|
|
2476
2516
|
},
|
|
2477
2517
|
_loading: {
|
|
2478
2518
|
state: true
|
|
2519
|
+
},
|
|
2520
|
+
_expired: {
|
|
2521
|
+
state: true
|
|
2522
|
+
},
|
|
2523
|
+
_failed: {
|
|
2524
|
+
state: true
|
|
2479
2525
|
}
|
|
2480
2526
|
};
|
|
2481
2527
|
constructor() {
|
|
@@ -2490,18 +2536,26 @@ var ChatAttachment = class extends LitElement4 {
|
|
|
2490
2536
|
this.longPressActive = false;
|
|
2491
2537
|
this._decryptedUrl = null;
|
|
2492
2538
|
this._loading = false;
|
|
2539
|
+
this._expired = false;
|
|
2540
|
+
this._failed = false;
|
|
2493
2541
|
}
|
|
2494
2542
|
createRenderRoot() {
|
|
2495
2543
|
return this;
|
|
2496
2544
|
}
|
|
2497
2545
|
_handleDecrypt = async () => {
|
|
2498
|
-
if (!this.onDecrypt || this._decryptedUrl || this.attachment.type === "location" || !isSafeAttachmentSourceUrl(this.attachment.url)) return;
|
|
2546
|
+
if (!this.onDecrypt || this._decryptedUrl || this._expired || this._loading || this.attachment.type === "location" || !isSafeAttachmentSourceUrl(this.attachment.url)) return;
|
|
2499
2547
|
const { onDecrypt, attachment } = this;
|
|
2500
2548
|
this._loading = true;
|
|
2549
|
+
this._failed = false;
|
|
2501
2550
|
try {
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
|
|
2551
|
+
const outcome = await decryptAttachmentOutcome(() => onDecrypt(attachment.url), reportError);
|
|
2552
|
+
if (outcome.status === "ok") {
|
|
2553
|
+
this._decryptedUrl = outcome.url;
|
|
2554
|
+
} else if (outcome.status === "expired") {
|
|
2555
|
+
this._expired = true;
|
|
2556
|
+
} else {
|
|
2557
|
+
this._failed = true;
|
|
2558
|
+
}
|
|
2505
2559
|
} finally {
|
|
2506
2560
|
this._loading = false;
|
|
2507
2561
|
}
|
|
@@ -2518,7 +2572,9 @@ var ChatAttachment = class extends LitElement4 {
|
|
|
2518
2572
|
}
|
|
2519
2573
|
}
|
|
2520
2574
|
_maybeAutoDecrypt() {
|
|
2521
|
-
if (!this.onDecrypt || this._decryptedUrl)
|
|
2575
|
+
if (!this.onDecrypt || this._decryptedUrl || this._expired || this._failed) {
|
|
2576
|
+
return;
|
|
2577
|
+
}
|
|
2522
2578
|
const { type } = this.attachment;
|
|
2523
2579
|
if (type === "image" || type === "video") {
|
|
2524
2580
|
this._handleDecrypt();
|
|
@@ -2540,6 +2596,9 @@ var ChatAttachment = class extends LitElement4 {
|
|
|
2540
2596
|
></chat-location-card>
|
|
2541
2597
|
`;
|
|
2542
2598
|
}
|
|
2599
|
+
if (this._expired) {
|
|
2600
|
+
return expiredAttachmentHtml(attachment, isDark);
|
|
2601
|
+
}
|
|
2543
2602
|
if (attachment.type === "audio") {
|
|
2544
2603
|
return this._decryptedUrl ? html5`
|
|
2545
2604
|
<chat-audio-player
|
|
@@ -2581,7 +2640,7 @@ var ChatAttachment = class extends LitElement4 {
|
|
|
2581
2640
|
alt="${attachment.name}"
|
|
2582
2641
|
style="max-width:100%;border-radius:8px;cursor:pointer;transition:transform .15s,box-shadow .15s${isSelected ? ";transform:scale(1.02);box-shadow:0 0 16px rgba(100,100,255,0.4)" : ""}${this.longPressActive && isSelected ? ";animation:msg-highlight .3s ease forwards" : ""}"
|
|
2583
2642
|
/>
|
|
2584
|
-
` : html5`
|
|
2643
|
+
` : this._failed ? unavailableAttachmentHtml(isDark) : html5`
|
|
2585
2644
|
<div style="${imagePlaceholderStyle(isDark)}">${spinnerHtml(isDark)}</div>
|
|
2586
2645
|
`;
|
|
2587
2646
|
}
|
|
@@ -2592,7 +2651,7 @@ var ChatAttachment = class extends LitElement4 {
|
|
|
2592
2651
|
.isDark="${isDark}"
|
|
2593
2652
|
.name="${attachment.name}"
|
|
2594
2653
|
></chat-video-player>
|
|
2595
|
-
` : html5`
|
|
2654
|
+
` : this._failed ? unavailableAttachmentHtml(isDark) : html5`
|
|
2596
2655
|
<div style="${videoPlaceholderStyle(isDark)}">${spinnerHtml(isDark)}</div>
|
|
2597
2656
|
`;
|
|
2598
2657
|
}
|
package/mod.js
CHANGED
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
getConversationKey,
|
|
14
14
|
getOrCreateConversation,
|
|
15
15
|
handleWebhookUpdate,
|
|
16
|
+
isAttachmentExpiredError,
|
|
16
17
|
loadCredentials,
|
|
17
18
|
loadOrCreateCredentials,
|
|
18
19
|
parseChatWithUrl,
|
|
@@ -20,6 +21,8 @@ import {
|
|
|
20
21
|
renameConversation,
|
|
21
22
|
resetSeenWebhookMessages,
|
|
22
23
|
resolveHandle,
|
|
24
|
+
retentionDays,
|
|
25
|
+
retentionMs,
|
|
23
26
|
saveCredentials,
|
|
24
27
|
sendInitialMessage,
|
|
25
28
|
sendMessage,
|
|
@@ -44,7 +47,7 @@ import {
|
|
|
44
47
|
uiUpdateUrl,
|
|
45
48
|
uploadAttachment,
|
|
46
49
|
verifyWebhookOrigin
|
|
47
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-45LBWUH3.js";
|
|
48
51
|
import {
|
|
49
52
|
aliasToPublicSignKey,
|
|
50
53
|
buildSignedRequest,
|
|
@@ -283,6 +286,7 @@ export {
|
|
|
283
286
|
getTurnCredentialsSigned,
|
|
284
287
|
getUploadUrl,
|
|
285
288
|
handleWebhookUpdate,
|
|
289
|
+
isAttachmentExpiredError,
|
|
286
290
|
loadCredentials,
|
|
287
291
|
loadOrCreateCredentials,
|
|
288
292
|
maxEncryptedMessageLength,
|
|
@@ -292,6 +296,8 @@ export {
|
|
|
292
296
|
renameConversation,
|
|
293
297
|
resetSeenWebhookMessages,
|
|
294
298
|
resolveHandle,
|
|
299
|
+
retentionDays,
|
|
300
|
+
retentionMs,
|
|
295
301
|
saveCredentials,
|
|
296
302
|
sendMessage,
|
|
297
303
|
sendMessageWithKey,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "alice-and-bot",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.79",
|
|
4
4
|
"description": "A chat network for agents. Open-source, end-to-end encrypted messaging SDK, React chat UI, and embeddable widgets for AI agents and humans.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|