@evanp/activitypub-bot 0.39.3 → 0.39.4
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/activitypubclient.js +17 -1
- package/package.json +1 -1
package/lib/activitypubclient.js
CHANGED
|
@@ -291,6 +291,9 @@ export class ActivityPubClient {
|
|
|
291
291
|
let lastPolicy
|
|
292
292
|
const storedPolicy = await this.#policyStorage.get(parsed.origin)
|
|
293
293
|
if (!storedPolicy || storedPolicy === SignaturePolicyStorage.RFC9421) {
|
|
294
|
+
this.#logger.debug(
|
|
295
|
+
{ origin: parsed.origin, storedPolicy }, 'Signing with RFC9421'
|
|
296
|
+
)
|
|
294
297
|
lastPolicy = SignaturePolicyStorage.RFC9421
|
|
295
298
|
headers = {
|
|
296
299
|
...baseHeaders,
|
|
@@ -299,6 +302,9 @@ export class ActivityPubClient {
|
|
|
299
302
|
const sigHeaders = await this.#messageSign({ username, url, method, headers })
|
|
300
303
|
Object.assign(headers, sigHeaders || {})
|
|
301
304
|
} else if (storedPolicy === SignaturePolicyStorage.DRAFT_CAVAGE_12) {
|
|
305
|
+
this.#logger.debug(
|
|
306
|
+
{ origin: parsed.origin, storedPolicy }, 'Signing with draft-cavage-12'
|
|
307
|
+
)
|
|
302
308
|
lastPolicy = SignaturePolicyStorage.DRAFT_CAVAGE_12
|
|
303
309
|
headers = {
|
|
304
310
|
...baseHeaders,
|
|
@@ -321,6 +327,11 @@ export class ActivityPubClient {
|
|
|
321
327
|
}
|
|
322
328
|
)
|
|
323
329
|
if ([401, 403].includes(res.status) && !storedPolicy) {
|
|
330
|
+
const body = await res.text()
|
|
331
|
+
this.#logger.debug(
|
|
332
|
+
{ url, status: res.status, body, headers: res.headers },
|
|
333
|
+
'Authentication error; retrying with draft-cavage-12 signature'
|
|
334
|
+
)
|
|
324
335
|
lastPolicy = SignaturePolicyStorage.DRAFT_CAVAGE_12
|
|
325
336
|
headers = {
|
|
326
337
|
...baseHeaders,
|
|
@@ -340,10 +351,15 @@ export class ActivityPubClient {
|
|
|
340
351
|
await this.#limiter.update(hostname, res.headers)
|
|
341
352
|
this.#logger.debug({ url }, 'Done fetching POST')
|
|
342
353
|
if (res.status < 200 || res.status > 299) {
|
|
354
|
+
const body = await res.text()
|
|
355
|
+
this.#logger.debug(
|
|
356
|
+
{ url, status: res.status, body, headers: res.headers },
|
|
357
|
+
'Error posting to url'
|
|
358
|
+
)
|
|
343
359
|
throw new ActivityPubClientError(
|
|
344
360
|
res.status,
|
|
345
361
|
`Could not post to ${url}`,
|
|
346
|
-
{ url, method, headers: res.headers }
|
|
362
|
+
{ url, method, headers: res.headers, body }
|
|
347
363
|
)
|
|
348
364
|
}
|
|
349
365
|
if (!storedPolicy && lastPolicy) {
|