libp2r2p 0.11.2 → 0.11.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/README.md
CHANGED
|
@@ -912,4 +912,5 @@ Private-message consumers can now substitute recovery persistence through
|
|
|
912
912
|
[`private-messenger/event-store`](private-messenger/event-store/README.md), or use
|
|
913
913
|
local defaults, including a bounded streaming file cache. The optional
|
|
914
914
|
[`private-messenger/session`](private-messenger/session/README.md) coordinator
|
|
915
|
-
provides reusable DM inbox/outbox and attachment lifecycle without UI coupling
|
|
915
|
+
provides reusable DM inbox/outbox and attachment lifecycle without UI coupling,
|
|
916
|
+
including an optional `onSendError` callback identifying the failed outbox message.
|
package/package.json
CHANGED
|
@@ -14,8 +14,16 @@ persistence; absent file storage uses the library cache. `mode` defaults to
|
|
|
14
14
|
|
|
15
15
|
Methods: `setPeers`, `setAvailable(boolean)`, `enqueue`, `retry`, `cancel`,
|
|
16
16
|
`download`, `cancelDownload`, and `close`. Callbacks are `onOutbox`, `onMedia`,
|
|
17
|
-
and `
|
|
18
|
-
to availability and owns view subscriptions. There are no DOM or UI imports.
|
|
17
|
+
`onError`, and optional `onSendError(error, { id, peer })`. The caller maps its
|
|
18
|
+
account permissions/connectivity/lock state to availability and owns view subscriptions. There are no DOM or UI imports.
|
|
19
|
+
|
|
20
|
+
`onSendError` identifies the main outbox message even when its quote, metadata,
|
|
21
|
+
file chunks, or local persistence failed. The original error is also reported to
|
|
22
|
+
`onError` unchanged. It fires once per failed send attempt (including retries),
|
|
23
|
+
not when persisted failures are read, nor for inbox/download/deletion operations
|
|
24
|
+
or cancelled/closed sends. Apps own route visibility and user-intent filtering;
|
|
25
|
+
automatic retries may also fail. Callbacks must not throw. Errors are not copied
|
|
26
|
+
into persisted outbox records.
|
|
19
27
|
|
|
20
28
|
`enqueue({ peer, event, context, requiredFiles, deletion })` preserves prepared
|
|
21
29
|
identities. Local message commits and remote stages have independent checkpoints.
|
|
@@ -16,7 +16,7 @@ export function wireEvent (value, owner) {
|
|
|
16
16
|
// Relay rejection text must not be interpreted as a local signer denial.
|
|
17
17
|
const retryable = error => error?.code === 'MESSAGE_NOT_PUBLISHED' || !/DENIED|PERMISSION|REVOKED|READ_ONLY|INVALID|BLOCKED|EXPIRED|NOT_IN_PERSONA/i.test(`${error?.code || ''} ${error?.message || ''}`)
|
|
18
18
|
|
|
19
|
-
export function createPrivateMessageSession ({ owner, signer, eventStore, messageStorage, chunkStorage, recoveryStorage, mode = 'seeder', seedersForPeer = peer => [peer], allowedKinds = [5, 9, 1063, 34601], onMedia = () => {}, onOutbox = () => {}, onError = () => {}, Messenger = createPrivateMessenger, openOutbox = createChatOutbox, FileTransfer = createPrivateFileTransfer, openDownloads = options => createChatOutbox({ ...options, namespace: 'downloads' }) }) {
|
|
19
|
+
export function createPrivateMessageSession ({ owner, signer, eventStore, messageStorage, chunkStorage, recoveryStorage, mode = 'seeder', seedersForPeer = peer => [peer], allowedKinds = [5, 9, 1063, 34601], onMedia = () => {}, onOutbox = () => {}, onError = () => {}, onSendError = () => {}, Messenger = createPrivateMessenger, openOutbox = createChatOutbox, FileTransfer = createPrivateFileTransfer, openDownloads = options => createChatOutbox({ ...options, namespace: 'downloads' }) }) {
|
|
20
20
|
const userSigner = messengerSigner(signer)
|
|
21
21
|
messageStorage ||= createEventStoreMessageStorage({ eventStore })
|
|
22
22
|
chunkStorage ||= eventStore ? createEventStoreChunkStorage({ eventStore }) : undefined
|
|
@@ -207,7 +207,14 @@ export function createPrivateMessageSession ({ owner, signer, eventStore, messag
|
|
|
207
207
|
entries.delete(entry.id)
|
|
208
208
|
emit()
|
|
209
209
|
} catch (error) {
|
|
210
|
-
if (cancelled.has(entry.id)) { await storage.remove(entry.id); entries.delete(entry.id) } else {
|
|
210
|
+
if (cancelled.has(entry.id)) { await storage.remove(entry.id); entries.delete(entry.id) } else {
|
|
211
|
+
entry.status = 'error'; entry.failed = true; entry.retryable = retryable(error)
|
|
212
|
+
await storage.put(entry, { existing: true }).catch(onError)
|
|
213
|
+
onError(error)
|
|
214
|
+
// The failed wire event may be a quote or file chunk. Report the
|
|
215
|
+
// owning outbox item separately, without mutating the native error.
|
|
216
|
+
if (!closed && !entry.deletion && !cancelled.has(entry.id)) onSendError(error, { id: entry.id, peer: entry.peer })
|
|
217
|
+
}
|
|
211
218
|
emit()
|
|
212
219
|
}
|
|
213
220
|
}
|